Keyup event fired too late #6

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

Projects

None yet

2 participants

@hlindset
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.

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.

Contributor

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

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?

Contributor

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 delambo added a commit that referenced this issue Sep 25, 2012
@delambo delambo issue #6 Keyup event fired too late 828fa69
Member
delambo commented Sep 25, 2012

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

@delambo delambo closed this Sep 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment