WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
243289
:focus-visible matches when an element is focused in an anchor’s click listener
https://bugs.webkit.org/show_bug.cgi?id=243289
Summary
:focus-visible matches when an element is focused in an anchor’s click listener
harry-moore
Reported
2022-07-28 03:16:19 PDT
When using a mouse to click an anchor which triggers a script that sets focus to another element, the focused element matches :focus-visible. On a single page application this is really noticeable and arguably not desired behaviour. See
https://codepen.io/HazzMan2409/pen/rNdYNpa
Note this is very similar to this bug
https://bugs.webkit.org/show_bug.cgi?id=236782
Maybe this issue occurs with other elements (not just anchors).
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2022-08-04 03:17:14 PDT
<
rdar://problem/98113373
>
Brian Birtles
Comment 2
2024-01-08 00:49:00 PST
Not just clicking with a mouse, but tapping on iOS too.
harry-moore
Comment 3
2025-12-09 04:11:46 PST
I am closing this off because after looking into it this is not a bug. A couple of notes: * on iOS and macOS ports of WebKit, an anchor element does not get focus on pointing device click. * :focus-visible should only match on script focus if the previously focused element matched :focus-visible. This is based on the spec guidelines which WebKit strives to implement ->
https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo
When loading a page and then clicking an anchor element like in the linked code pen, since the anchor element never gets focus, there is no previously focused element and so all bets are off. :focus-visible matching is acceptable! If, however, the anchor is made focusable by adding a tabindex then :focus-visible should not match. This is the current behavior!
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug