-
Notifications
You must be signed in to change notification settings - Fork 235
fix(tray): add visually hidden dismiss buttons #5814
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
Merged
rise-erpelding
merged 19 commits into
main
from
marissahuysentruyt/swc-274-tray-visually-hidden-bug
Nov 5, 2025
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4bacaa4
feat(tray): add dismissHelper function
marissahuysentruyt 1d100df
refactor(tray): expand visually-hidden selector for dismiss buttons
marissahuysentruyt 713b3cf
docs(tray): add tray docs with visually hidden dismiss
marissahuysentruyt 4a83701
feat(dialog-base): add dismissHelper for visually-hidden buttons
marissahuysentruyt 5692d4a
feat(dialog-wrapper): implement conditional dismissHelper buttons
marissahuysentruyt 864b45a
feat(modal): add visually-hidden styles for dialog dismissHelpers
marissahuysentruyt 7fa4615
revert: feat(modal): add visually-hidden styles for dialog dismissHel…
marissahuysentruyt 970b87c
revert: feat(dialog-wrapper): implement conditional dismissHelper but…
marissahuysentruyt f8a8604
revert: feat(dialog-base): add dismissHelper for visually-hidden buttons
marissahuysentruyt 361d586
feat(tray): expand API for dismissible behavior
marissahuysentruyt 12ecf8b
docs(tray): update README with new properties/examples
marissahuysentruyt 2162d6d
test(tray): add tests for dismiss button detection
marissahuysentruyt 93b8296
chore(tray): add changeset
marissahuysentruyt 9a7f9ba
chore(tray): fix type errors
marissahuysentruyt fc87378
test(tray): fix failing close test
marissahuysentruyt ebd0b3d
fix(tray): remove negative tabindex fromhidden buttons
marissahuysentruyt c563c2d
test(tray): add keyboard accessible test assertion
marissahuysentruyt 6662f31
docs(tray): update docs with keyboard nav info
marissahuysentruyt a084f4e
test(tray): add tab and close() keyboard tests
marissahuysentruyt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| '@spectrum-web-components/tray': minor | ||
| --- | ||
|
|
||
| **Added**: Automatic dismiss button detection and visually-hidden helpers for screen reader accessibility | ||
|
|
||
| - **Added**: `<sp-tray>` now automatically detects keyboard-accessible dismiss buttons (like `<sp-button>`, `<sp-close-button>`, or HTML `<button>` elements) in slotted content | ||
| - **Added**: When no dismiss buttons are detected, the tray automatically renders visually-hidden dismiss buttons before and after its content to support mobile screen readers (particularly VoiceOver on iOS) | ||
| - **Added**: New `has-keyboard-dismiss` boolean attribute to manually override auto-detection when slotted content has custom dismiss functionality that cannot be automatically detected | ||
| - **Added**: Auto-detection recognizes `<sp-dialog dismissable>` and `<sp-dialog-wrapper dismissable>` components with built-in dismiss functionality in shadow DOM | ||
| - **Enhanced**: Improved mobile screen reader accessibility by ensuring dismissal options are always available when appropriate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Because tray-modal has a
tabindex="-1", I still can't get to the dismiss buttons with a keyboardThere 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.
Let me know if I'm still missing anything here. Without removing the
tabindex="-1"on the.tray.modal, I can still tab to the buttons.Screen.Recording.2025-10-24.at.2.11.49.PM.mov
Did we want some sort of focus indicator? What's the expectation if the button is visually hidden, but keyboard accessible? 🤔
