Closed
Bug 1400362
Opened 7 years ago
Closed 7 years ago
window.confirm returns true on ENTER with Cancel button focused
Categories
(Firefox :: Untriaged, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: eschiebel, Unassigned)
Details
Attachments
(1 file)
201 bytes,
text/html
|
Details |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0
Build ID: 20170824053838
Steps to reproduce:
with 55.0.3 (64-bit) on MacOS 10.12.6 (16G29)
call window.confirm
when confirmation dialog opens, the Cancel button has focus
type ENTER
attached html file can be used to reproduce the issue
this works as expected on Windows
Actual results:
window.confirm returns true as if I clicked OK
Expected results:
window.confirm returns false
![]() |
||
Comment 1•7 years ago
|
||
> when confirmation dialog opens, the Cancel button has focus
No, neither button has focus. You can tell because neither has a focus outline, and pressing space (which is what triggers the focused button on Mac) doesn't trigger either button.
> window.confirm returns true as if I clicked OK
This is the expected behavior on Mac, as far as I can tell. Enter triggers the default button on Mac, which is OK in the case of window.confirm. Space is what triggers the focused button.
I just tested some other browsers on Mac. Safari has the same behavior as Firefox. Chrome focuses the "Cancel" button by default, but enter triggers the "OK" button, as expected.
The dialog UI rules are a bit different on Windows. There enter and space both trigger the focused button, not the default button....
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Flags: needinfo?(zakharin)
Resolution: --- → INVALID
Yes, chrome focuses the Cancel button, as can be seen by the blue glow around it, which I find very confusing that Enter clicks OK. I misrepresented what FF does wrt focus, my bad. I don't know how you can tell what button has focus on Safari, as it doesn't show the focus indicator at all, unless neither button is focused and Tab doesn't move focus to either of the buttons - which is another story altogether.
Thanks.
![]() |
||
Comment 3•7 years ago
|
||
> which I find very confusing that Enter clicks OK
That's just how dialogs on Mac work, including system dialogs: Enter clicks the default button no matter where the focus is. That's why the default button is generally clearly highlighted on Mac dialogs. Our confirm dialog doesn't do a great job of this last bit....
> unless neither button is focused and Tab doesn't move focus to either of the buttons
That is exactly the Safari behavior for this dialog. So for this dialog it always has Enter == OK, Escape == Cancel, click == whatever you clicked, space == no response.
You need to log in
before you can comment on or make changes to this bug.
Description
•