Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syn.type() with [escape] string does press escape, but also appends escape text #198

Open
mvorisek opened this issue May 6, 2023 · 1 comment · May be fixed by #199
Open

syn.type() with [escape] string does press escape, but also appends escape text #198

mvorisek opened this issue May 6, 2023 · 1 comment · May be fixed by #199

Comments

@mvorisek
Copy link

mvorisek commented May 6, 2023

v0.15.0 / latest

repro:

  1. create a page with some <input control` (or download https://dev.atk4.org/demos/javascript/vue-component.php source)
  2. include syn.js
  3. in developer console eval window.syn.type($('input[name=atk_fp_country__name]')[0], '[escape]', function () {})
  4. notice the esc key is pressed (=detected by JS), but the input value flashes with escape text appended shortly, which is not expected nor normally appended by a native event

image

PS with [backspace] I do not observe a simillar problem.

@justinbmeyer any idea how to fix it?

@mvorisek mvorisek changed the title syn.type with [escape] input does press escape, but also appends escape text syn.type() with [escape] input does press escape, but also appends escape text May 6, 2023
@mvorisek mvorisek changed the title syn.type() with [escape] input does press escape, but also appends escape text syn.type() with [escape] text does press escape, but also appends escape text May 6, 2023
@mvorisek mvorisek changed the title syn.type() with [escape] text does press escape, but also appends escape text syn.type() with [escape] string does press escape, but also appends escape text May 6, 2023
@mvorisek
Copy link
Author

mvorisek commented Sep 9, 2023

here is a log of events fired natively:

image

such log can be easily enabled in Firefox:

image

UPDATE: the blur was called by https://github.com/atk4/ui/blob/1ea7959cbd/js/src/vue-components/inline-edit.component.js#L71 - natively, it is not emit


in syn.js, currently, additional events caused by a keypress are defined in https://github.com/bitovi/syn/blob/c9dfa58449/src/key.js#L546 (for [enter] key for example) and triggered in https://github.com/bitovi/syn/blob/c9dfa58449/src/key.js#L850

for [escape] this is currently not working as:
a) escape has no defaults like l546 for enter defined
b) keyup is always called after - https://github.com/bitovi/syn/blob/c9dfa58449/src/key.js#L879 - but it needs to be called prior blur event - so adding escape defaults like:

            'escape': function () {
                var nodeName = this.nodeName.toLowerCase();
                if (document.activeElement === this) {
                    if (nodeName === 'input' || nodeName === 'textarea') {
                        syn.trigger(this, 'change', {});
                        syn.trigger(this, 'blur', {});
                    }
                }
            },

is not enough

the escape keyup ((if changed) -> change) -> blur order is important as blur is often used to handle changes and escape key to clear them


the syn.js events order can be debug by:

window.syn.type(document.getElementsByName("atk_fp_country__name")[0], 'x[escape]', () => console.log('syn complete'))

from F12 console

@mvorisek mvorisek linked a pull request Sep 9, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant