WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
242456
Implement FocusOptions.focusVisible
https://bugs.webkit.org/show_bug.cgi?id=242456
Summary
Implement FocusOptions.focusVisible
Emilio Cobos Álvarez (:emilio)
Reported
2022-07-07 10:22:28 PDT
See discussion at the URL.
Attachments
Add attachment
proposed patch, testcase, etc.
Alexey Proskuryakov
Comment 1
2022-07-07 19:12:40 PDT
It's a bit surprising that one would would want to draw focus outline without actually focusing? And if they do that, it would be super confusing to the user.
Emilio Cobos Álvarez (:emilio)
Comment 2
2022-07-08 02:52:50 PDT
(In reply to Alexey Proskuryakov from
comment #1
)
> It's a bit surprising that one would would want to draw focus outline > without actually focusing? And if they do that, it would be super confusing > to the user.
Hm? That's not the point, you'd draw (or not) the outline only if the element gets focus. This only overrides the default behavior which is an heuristic.
Emilio Cobos Álvarez (:emilio)
Comment 3
2022-07-08 03:04:05 PDT
I added a test for non-focusable elements to my patch.
Radar WebKit Bug Importer
Comment 4
2022-07-14 10:23:15 PDT
<
rdar://problem/97021844
>
Fotis Papadogeorgopoulos
Comment 5
2023-10-24 11:13:51 PDT
Hi! Have there been any updates on this? Having a way to prompt :focus-visible with programmatic focus would be very useful, to work around cases where the heuristics fall short. This is not a judgement, it’s just that whenever heuristics are involved, there should be a way to override them. At Wolt (wolt.com), we ran into one such case when we updated our selectors to use :focus-visible. We wanted to align with browser heuristics, to ship less JS and be able to debug with the browser devtools (compared to the polyfill). We do focus trapping for our modals (and some other areas), where we intercept and `preventDefault` relevant keyboard events. When we do so, we instead call .focus() on the next item in the focus scope. In those cases, Safari’s heuristics do not always work. If the user is only browsing with the keyboard, :focus-visible matches. However, if the user opens the modal with a pointer, but chooses to continue with the keyboard, then they do not get a :focus-visible style! This is arguably an accessibility failure regarding concurrent input mechanisms. There are two bugs that seem related to this use-case:
https://bugs.webkit.org/show_bug.cgi?id=246591
https://bugs.webkit.org/show_bug.cgi?id=258987
However, I am making the case that if we had access to the `focusVisible` option, we would not need to wait for those bugs to be resolved. I think the original GitHub discussion is exactly on point about identifying the need for this. For posterity: We introduced a lever to override :focus-visible by introducing a selector like this: `:is(:focus-visible, [data-force-focus-visible])`. We manually set `data-force-focus-visible` when calling `.focus()` inside the modal/focus scope. This works, but needs all components to be use it (since most components might be inside a modal), runtime JS, co-ordination between teams, and a shared linting rule around `:focus-visible`. If we could rely on the `focusVisible` option, we could avoid all that :) I believe this same problem would show up for shared libraries, where co-ordinating a special selector to override :focus-visible might be even harder. Please let me know if there is any other information that I can provide, to help motivate this.
Luke Warlow
Comment 6
2024-08-28 09:49:30 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/32833
EWS
Comment 7
2024-12-17 12:17:35 PST
Committed
287959@main
(20aaacc363ae): <
https://commits.webkit.org/287959@main
> Reviewed commits have been landed. Closing PR #32833 and removing active labels.
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