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

Keyup event fired too late #6

Closed
hlindset opened this issue Sep 24, 2012 · 5 comments
Closed

Keyup event fired too late #6

hlindset opened this issue Sep 24, 2012 · 5 comments

Comments

@hlindset
Copy link
Contributor

There seems to be an issue with the keyup event being fired on the wrong field when quickly tabbing to the next field after typing. The keyup event is being fired on the field that was tabbed to instead of on the field that was typed in.

Steps to reproduce:

  1. Type "testing" in an input field
  2. Quickly tab away from the field

After doing this the model's attribute will be "testin", as the field never received the last keyup event.

@delambo
Copy link
Member

delambo commented Sep 24, 2012

@hlindset Thanks for the report.

I'm trying to replicate here:

http://jsfiddle.net/delambo/MNRH5/

I'm not experiencing that behavior when I tab away quickly - you can see the model attribute populated in the DOM and in the console. Let me know if I got the test case wrong.

@hlindset
Copy link
Contributor Author

It happens when tab is pressed at almost the same time as the last character I type.

Here's an updated fiddle that prints the source element for the keyup event:
http://jsfiddle.net/9y4zu/

And a video demonstrating the behaviour:
http://screenr.com/cmP8

@delambo
Copy link
Member

delambo commented Sep 24, 2012

@hlindset Thanks for the modified fiddle and vid.

I think the tab keyup is firing before the last character keyup event. You can see this behavior when you hold down one key until it displays several characters, then without letting go hit the tab key, then after the tab has clearly moved to the next input let go of the key. Notice how you lose that last keyup/character which is exactly what happens in your examples.

Does this sound plausible?

@hlindset
Copy link
Contributor Author

Yes, sounds plausible to me.

The focus change when tabbing happens on keydown, so when the keyup event fires the focus has already been changed, thus the keyup event is fired for the "wrong" element. Binding the change-event in addition to keyup would solve that.

delambo added a commit that referenced this issue Sep 25, 2012
@delambo
Copy link
Member

delambo commented Sep 25, 2012

@hlindset Thanks for the help. I got this resolved on master.

@delambo delambo closed this as completed Sep 25, 2012
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

No branches or pull requests

2 participants