Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11638 closed bug (invalid)

PreventDefault in keypress event cancels change event after multiple calls.

Reported by: admin@… Owned by:
Priority: low Milestone: None
Component: event Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:


Returning false or using preventDefault from a keypress handler for a textbox, will prevent a change event from triggering for the same textbox after multiple calls.

The steps to reproduce this bug are in the following jsFiddle: http://jsfiddle.net/portablesheep/hYmue/9/

You'll notice this example is using keypress to detect enter, and subsequently click a button. This example was chosen as it's a scenario I ran into at work.

Change History (2)

comment:1 Changed 11 years ago by Rick Waldron

Component: unfiledevent
Priority: undecidedlow
Resolution: invalid
Status: newclosed

I followed your instructions to the letter and I'm not sure how you didn't notice that your own documented instructions provide the answer you need:

  1. Enter "1234" into the box, and press enter. -> Notice 'Submitted!' text.
  2. Press backspace, and then press tab. -> Notice 'Changed!' text.
  3. Place caret at end of the text, and press 4, followed by enter. -> Notice 'Submitted!' text.
  4. Press backspace, and then press tab. -> Notice 'Submitted!' text, when it should be 'Changed!'
  1. The input is blurred as a result of tabbing away, the value is "123", a change event occurs
  2. Restore focus by clicking back into the input
  3. Change the value to "1234"
  4. Delete "4", the value is "123"
  5. The input is blurred as a result of tabbing away, the value is "123"

... Nothing has changed since the change event at #1, it is still "123"

Last edited 11 years ago by Rick Waldron (previous) (diff)

comment:2 Changed 11 years ago by anonymous

I see what you're saying. I was under the impression that by pressing enter in this case with a different value than the original, that the change event would occur. I didn't think about the blur being the trigger, and blur not occurring in this scenario.

Note: See TracTickets for help on using tickets.