Closed Bug 1058046 Opened 10 years ago Closed 10 years ago

javascript problem with input keeping focus while alert is shown

Categories

(Core :: DOM: Events, defect)

31 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: shadowoflink, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0 (Beta/Release) Build ID: 20140716183446 Steps to reproduce: - Assign jQuery trigger .keyup() on input element which prompt an alert on keyup of the enter key - Hit enter while focus on input to trigger alert - Validate alert using the enter key Here's a jsfiddle for the demo : http://jsfiddle.net/mhbg6aa3/2/ And here's a gist link : https://gist.github.com/anonymous/6d8b79158e9218097338 Note : The problem is only with the keyup event, the keydown one is fine. Actual results: Alert is closing and opening again, resulting into a loop of alert if you close them with the enter key Expected results: Alert should close and not re-open
Component: Untriaged → DOM: Events
Product: Firefox → Core
I don't think this is a bug. In native dialogs on Mac as well as Windows, a dialog is dismissed on keydown of the enter key. The fact that the keyup then occurs elsewhere is to be expected, because the original dialog is gone - focus should be *somewhere*. So the keyup event fires on the focused element - the input box. Other browsers behave in the same manner.
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
(In reply to :Gijs Kruitbosch from comment #1) > I don't think this is a bug. > > In native dialogs on Mac as well as Windows, a dialog is dismissed on > keydown of the enter key. The fact that the keyup then occurs elsewhere is > to be expected, because the original dialog is gone - focus should be > *somewhere*. So the keyup event fires on the focused element - the input box. > > Other browsers behave in the same manner. I agree with the fact of the event having to occur somewhere because the dialog is dismissed, however Firefox is the only one to react like this. I tried it with latest version of Chrome and even Internet Explorer, and those two do not trigger the keyup event (at least not as long as the key does not stay down long).
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
(In reply to shadowoflink from comment #2) > (In reply to :Gijs Kruitbosch from comment #1) > > I don't think this is a bug. > > > > In native dialogs on Mac as well as Windows, a dialog is dismissed on > > keydown of the enter key. The fact that the keyup then occurs elsewhere is > > to be expected, because the original dialog is gone - focus should be > > *somewhere*. So the keyup event fires on the focused element - the input box. > > > > Other browsers behave in the same manner. > > I agree with the fact of the event having to occur somewhere because the > dialog is dismissed, however Firefox is the only one to react like this. I > tried it with latest version of Chrome and even Internet Explorer, and those > two do not trigger the keyup event (at least not as long as the key does not > stay down long). The fact that we manage to restore focus to the input box more quickly than IE or Chrome if you press the enter key 'really quickly' isn't really a bug either, and you've provided no alternative as to where you think focus should go - and the website code will need to deal with the same eventuality in other browsers in case the key is pressed "too long" anyway.
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago10 years ago
Resolution: --- → INVALID
(In reply to :Gijs Kruitbosch from comment #3) > (In reply to shadowoflink from comment #2) > > (In reply to :Gijs Kruitbosch from comment #1) > > > I don't think this is a bug. > > > > > > In native dialogs on Mac as well as Windows, a dialog is dismissed on > > > keydown of the enter key. The fact that the keyup then occurs elsewhere is > > > to be expected, because the original dialog is gone - focus should be > > > *somewhere*. So the keyup event fires on the focused element - the input box. > > > > > > Other browsers behave in the same manner. > > > > I agree with the fact of the event having to occur somewhere because the > > dialog is dismissed, however Firefox is the only one to react like this. I > > tried it with latest version of Chrome and even Internet Explorer, and those > > two do not trigger the keyup event (at least not as long as the key does not > > stay down long). > > The fact that we manage to restore focus to the input box more quickly than > IE or Chrome if you press the enter key 'really quickly' isn't really a bug > either, and you've provided no alternative as to where you think focus > should go - and the website code will need to deal with the same eventuality > in other browsers in case the key is pressed "too long" anyway. I did not provide any alternative because i thought chrome and other browsers implemented a timer before triggering another event after the dialog is closed. Now you say it, it's indeed likely that Firefox restores the focus to the input box more quickly than other browsers, or at least it's seems more realistic than a specific timer for such an action. Weird behavior at first thought, does not looks like a bug anymore to me.
Resolution: INVALID → WONTFIX
Resolution: WONTFIX → INVALID
You need to log in before you can comment on or make changes to this bug.