javascript problem with input keeping focus while alert is shown

RESOLVED INVALID

Status

()

RESOLVED INVALID
4 years ago
4 years ago

People

(Reporter: shadowoflink, Unassigned)

Tracking

31 Branch
x86_64
Windows 7
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

4 years ago
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

Updated

4 years ago
Component: Untriaged → DOM: Events
Product: Firefox → Core

Comment 1

4 years ago
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
Last Resolved: 4 years ago
Resolution: --- → INVALID
(Reporter)

Comment 2

4 years ago
(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 → ---

Comment 3

4 years ago
(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
Last Resolved: 4 years ago4 years ago
Resolution: --- → INVALID
(Reporter)

Comment 4

4 years ago
(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

Updated

4 years ago
Resolution: WONTFIX → INVALID
You need to log in before you can comment on or make changes to this bug.