Bug Tracker

Ticket #11638 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

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:
Blocking: Blocked by:

Description

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

comment:1 Changed 2 years ago by rwaldron

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to event

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"

Version 1, edited 2 years ago by rwaldron (previous) (next) (diff)

comment:2 Changed 2 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.