RESOLVED CONFIGURATION CHANGED 112968
FKA: mouse click on buttons causes focus (document.activeElement) to be lost
https://bugs.webkit.org/show_bug.cgi?id=112968
Summary FKA: mouse click on buttons causes focus (document.activeElement) to be lost
James Craig
Reported 2013-03-21 14:44:22 PDT
REPRO * 1. Load attached test case. 2. Tab so that focus is on one of the buttons. 3. Perform a mouse click on the same button. (Notice focus ring disappears.) 4. Press Tab again. (focus has been lost and resets to the beginning of the document) Note: It's probably okay to "hide" the focus pseudo-state when switching to a mouse, but Tabbing should cause focus to come back to the same element rather than losing document.activeElement entirely.
Attachments
test case demonstrating bug (274 bytes, text/html)
2013-03-21 14:47 PDT, James Craig
no flags
James Craig
Comment 1 2013-03-21 14:47:19 PDT
Created attachment 194349 [details] test case demonstrating bug
Radar WebKit Bug Importer
Comment 2 2013-03-21 14:48:14 PDT
James Craig
Comment 3 2013-03-21 14:48:42 PDT
See expected behavior in Firefox 19 for Mac.
Radar WebKit Bug Importer
Comment 4 2013-03-21 14:49:02 PDT
Alexey Proskuryakov
Comment 5 2013-03-22 15:51:21 PDT
See also: bug 22261.
James Craig
Comment 6 2015-03-11 23:20:37 PDT
Mu-An Chiou
Comment 7 2018-08-09 11:26:44 PDT
Any updates on this? I see that there's not been any changes since the bug was reported 5 years ago. This issue makes building custom widget with focus management very tricky.
James Craig
Comment 8 2021-06-14 12:08:19 PDT
Relating to the newer :focus-visible tracker in bug 225148
Manuel Rego Casasnovas
Comment 9 2022-04-06 00:36:16 PDT
Very related bug, see bug #229895.
Mu-An Chiou
Comment 10 2023-09-12 03:43:27 PDT
Just talked about this at TPAC with ntim and jcraig I just want to add to the repro steps: REPRO * 1. Load attached test case. 2. Tab so that focus is on one of the buttons. 3. Perform a mouse click on the same button. (Notice focus ring disappears.) 4. Press Tab again. (focus has been lost and resets to the beginning of the document) As of 16.6, step 4 is no longer the case. the next focus point does land on the button. However if you do `setInterval(() => console.log(document.activeElement), 1000)` to observe the current focused element, you would see that after step 3, the activeElement goes back to body. nTim mentioned that there has been a recent fix to account for how button[tabindex=0] should be click-focusable like div[tabindex=0]. https://github.com/WebKit/WebKit/pull/12743 Now that :focus-visible is implemented, I wonder if WebKit would mind reconsidering this special treatment (https://github.com/WebKit/WebKit/blob/b38121da42a0483fdb1bc13782f1c7a8059de100/Source/WebCore/html/HTMLFormControlElement.cpp#L255C13-L255C13) to buttons?
James Craig
Comment 11 2023-11-07 18:24:47 PST
Seems reasonable to me... When I filed this back in 2013, :focus-visible didn't exist so there wasn't a way to make this work for all use cases, but I think that wwide support of :focus-visible now unblocks this, right?
James Craig
Comment 12 2023-11-07 20:09:42 PST
Seems fixed in latest STP so this was probably resolved along with :focus-visible. Muan, if you know of other instances where this doesn't work, will you open a new issue?
Note You need to log in before you can comment on or make changes to this bug.