Bug 239472 - [selectors] Double script focus after mouse click shouldn't match :focus-visible
Summary: [selectors] Double script focus after mouse click shouldn't match :focus-visible
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari 15
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Manuel Rego Casasnovas
URL:
Keywords: InRadar
Depends on:
Blocks: 185859
  Show dependency treegraph
 
Reported: 2022-04-18 16:32 PDT by focusvisiblewebkitbugzilla
Modified: 2022-05-06 15:08 PDT (History)
9 users (show)

See Also:


Attachments
Test case to reproduce the issue (264 bytes, text/html)
2022-05-06 02:22 PDT, Manuel Rego Casasnovas
no flags Details
Patch (6.97 KB, patch)
2022-05-06 09:35 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description focusvisiblewebkitbugzilla 2022-04-18 16:32:36 PDT
Safari introduced :focus-visible support in 15.4. However, it behaves differently than Chrome and Firefox in that programmatically focusing elements will trigger :focus-visible styles. Many screens rely on programmatic focus for accessibility and are not expecting a focus ring to appear.

Example:
- Go to www.airbnb.com
- On the top right, click the globe icon to bring up a "language and region" modal
- Notice that the close button has a :focus-visible outline in Safari 15.4+ but not in Chrome or Firefox

Another report: 
- https://githubhot.com/repo/reach/reach-ui/issues/915

Desired result:
- :focus-visible in Safari should behave the same as Chrome and Firefox
Comment 1 Radar WebKit Bug Importer 2022-04-25 16:33:12 PDT
<rdar://problem/92301472>
Comment 2 Manuel Rego Casasnovas 2022-05-06 02:22:37 PDT
Created attachment 458942 [details]
Test case to reproduce the issue
Comment 3 Manuel Rego Casasnovas 2022-05-06 09:27:09 PDT
The problem with that website is that it was focusing the element several times via script.

The test case attached reproduce the issue. I'm working on a patch to fix it and behave consistently to Chromium and Firefox here.
Comment 4 Manuel Rego Casasnovas 2022-05-06 09:35:03 PDT
Created attachment 458956 [details]
Patch
Comment 5 EWS Watchlist 2022-05-06 09:36:53 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 6 EWS 2022-05-06 15:08:06 PDT
Committed r293926 (250373@main): <https://commits.webkit.org/250373@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 458956 [details].