-
Notifications
You must be signed in to change notification settings - Fork 229
fix(link): added delegateFocus for Safari tab index issue in shadow root #5580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: c4e0daf The changes in this PR will be included in the next version bump. This PR includes changesets to release 84 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📚 Branch Preview🔍 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Tachometer resultsChromelink permalinktest-basic
Firefoxlink permalinktest-basic
|
packages/link/src/Link.ts
Outdated
* This enables delegatesFocus for Safari compatibility | ||
*/ | ||
static override shadowRootOptions = { | ||
...LitElement.shadowRootOptions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually use spread ...SpectrumElement.shadowRootOptions
, should we also do it here?
expect(anchor.getAttribute('tabindex')).to.eq('0'); | ||
|
||
// WebKit-specific enhanced tests | ||
if (isWebKit()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can remove this check and run the assertions for all browsers... any reason we need to scope it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes there is an upstream issue around this. It is a known limitation of iOS/Safari with custom elements and shadow DOM. See WebKit bug reports and related issues.
Description
SWC Link components
<sp-link>
were not keyboard navigable on Safari/WebKit browsers, particularly when using external keyboards on iOS devices. Users could not Tab through links or use Enter/Space to activate them, making the component inaccessible in Safari.Motivation and context
Root Cause
tabindex="0"
, which Safari requires for keyboard navigationKey Changes
delegatesFocus: true
to shadow root configurationtabindex="0"
on anchor elementBreaking Changes
None. This is a non-breaking enhancement that improves Safari compatibility while maintaining all existing APIs, styling, and behavior.
Related issue(s)
Screenshots (if appropriate)
Author's checklist
Reviewer's checklist
patch
,minor
, ormajor
featuresManual review test cases
Safari Test
Chrome Test
Firefox Test
Device review