You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Added**: Automatic dismiss button detection and visually-hidden helpers for screen reader accessibility
6
+
7
+
-**Added**: `<sp-tray>` now automatically detects keyboard-accessible dismiss buttons (like `<sp-button>`, `<sp-close-button>`, or HTML `<button>` elements) in slotted content
8
+
-**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)
9
+
-**Added**: New `has-keyboard-dismiss` boolean attribute to manually override auto-detection when slotted content has custom dismiss functionality that cannot be automatically detected
10
+
-**Added**: Auto-detection recognizes `<sp-dialog dismissable>` and `<sp-dialog-wrapper dismissable>` components with built-in dismiss functionality in shadow DOM
11
+
-**Enhanced**: Improved mobile screen reader accessibility by ensuring dismissal options are always available when appropriate
Copy file name to clipboardExpand all lines: 1st-gen/packages/tray/README.md
+80-3Lines changed: 80 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,19 +7,19 @@
7
7
[](https://www.npmjs.com/package/@spectrum-web-components/tray)
8
8
[](https://bundlephobia.com/result?p=@spectrum-web-components/tray)
9
9
10
-
```
10
+
```zsh
11
11
yarn add @spectrum-web-components/tray
12
12
```
13
13
14
14
Import the side effectful registration of `<sp-tray>` via:
15
15
16
-
```
16
+
```js
17
17
import'@spectrum-web-components/tray/sp-tray.js';
18
18
```
19
19
20
20
When looking to leverage the `Tray` base class as a type and/or for extension purposes, do so via:
@@ -70,3 +70,80 @@ A tray has a single default `slot`.
70
70
### Accessibility
71
71
72
72
`<sp-tray>` presents a page blocking experience and should be opened with the `Overlay` API using the `modal` interaction to ensure that the content appropriately manages the presence of other content in the tab order of the page and the availability of that content for a screen reader.
73
+
74
+
#### Auto-detection behavior
75
+
76
+
By default, `<sp-tray>` automatically detects whether its slotted content includes keyboard-accessible dismiss buttons (like `<sp-button>`, `<sp-close-button>`, or HTML `<button>` elements). When no dismiss buttons are found, the tray renders visually hidden dismiss buttons before and after its content to support mobile screen readers, particularly VoiceOver on iOS where users navigate through interactive elements sequentially.
77
+
78
+
These built-in dismiss buttons:
79
+
80
+
- Are visually hidden but accessible to screen readers
81
+
- Allow mobile screen reader users to easily dismiss the tray from either the beginning or end of the content
82
+
- Are labeled "Dismiss" for clear screen reader announcements
83
+
84
+
This dismiss helper pattern is also implemented in the [`<sp-picker>`](https://opensource.adobe.com/spectrum-web-components/components/picker/) component, which uses the same approach when rendering menu content in a tray on mobile devices.
<sp-tabvalue="auto">Content has no buttons</sp-tab>
88
+
<sp-tab-panelvalue="auto">
89
+
90
+
This example shows the default behavior where the tray automatically detects that the menu content lacks dismiss buttons and renders visually hidden helpers. Screen readers will announce them as "Dismiss, button" and these helpers are keyboard accessible.
91
+
92
+
```html
93
+
<overlay-triggertype="modal">
94
+
<sp-buttonslot="trigger"variant="secondary">
95
+
Toggle menu content
96
+
</sp-button>
97
+
<sp-trayslot="click-content">
98
+
<sp-menustyle="width: 100%">
99
+
<sp-menu-item>Deselect</sp-menu-item>
100
+
<sp-menu-item>Select Inverse</sp-menu-item>
101
+
<sp-menu-item>Feather...</sp-menu-item>
102
+
<sp-menu-item>Select and Mask...</sp-menu-item>
103
+
</sp-menu>
104
+
</sp-tray>
105
+
</overlay-trigger>
106
+
```
107
+
108
+
</sp-tab-panel>
109
+
<sp-tabvalue="with-buttons">Content has buttons</sp-tab>
110
+
<sp-tab-panelvalue="with-buttons">
111
+
112
+
This example shows auto-detection recognizing that the dialog has its own dismiss functionality, so no additional helpers are rendered.
Set `has-keyboard-dismiss` (or `has-keyboard-dismiss="true"`) to prevent the tray from rendering visually hidden dismiss helpers, even when no buttons are detected. You are then responsible for ensuring that your tray content has keyboard-accessible dismiss functionality.
133
+
134
+
```html
135
+
<overlay-triggertype="modal">
136
+
<sp-buttonslot="trigger"variant="secondary">
137
+
Toggle without helpers
138
+
</sp-button>
139
+
<sp-trayslot="click-content"has-keyboard-dismiss>
140
+
<p>
141
+
Custom content that should have custom dismiss functionality, even
142
+
though the tray didn't detect buttons in this slot.
0 commit comments