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
fix(tabs): default keyboard-activation to automatic, matching React Spectrum (#6476)
<swc-tabs> inherited keyboard-activation="manual" as its default from
1st-gen sp-tabs' auto=false, not from a deliberate accessibility decision.
React Spectrum/React Aria Tabs defaults to automatic activation, and
swc-tab-panel content is always present in the light DOM (not lazily
mounted), which is the condition the WAI-ARIA APG recommends for
automatic activation. Flip the default to automatic and document manual
as consumer guidance for expensive/lazy-loaded panels instead.
Co-authored-by: Rajdeep Chandra <rajdeepc@adobe.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Patrick Fulton <360251+pfulton@users.noreply.github.com>
**fix(tabs):** Changed the default `keyboard-activation` on `<swc-tabs>` from `manual` to `automatic`, aligning with React Spectrum/React Aria `Tabs`.
6
+
7
+
`swc-tab-panel` content is always present in the light DOM (not lazily mounted), which is the condition the WAI-ARIA APG recommends for automatic activation. Consumers relying on the previous implicit `manual` default (inherited from 1st-gen `sp-tabs`' `auto = false`) should add `keyboard-activation="manual"` explicitly, particularly if their own panel content is expensive to render or lazy-loaded.
|`rovingTabindexController` field | Removed; keyboard navigation is internal |
68
68
|`focusElement` getter | Removed; use `tabsEl.focus()`|
69
69
70
+
> **Default activation mode changed.** In Spectrum 1, `<sp-tabs>` defaulted to manual activation (`auto` omitted or `false`): arrow keys moved focus without changing selection until Enter, Space, or click. Spectrum 2 defaults `keyboard-activation` to `automatic` to match React Spectrum's `Tabs`, so arrow keys now select immediately by default. If you were relying on the implicit manual default (no `auto` attribute) and your tab panels are expensive to render or not fully in the DOM, add `keyboard-activation="manual"` explicitly.
71
+
70
72
## Update your code
71
73
72
74
### 1. Rename the tags and attributes
@@ -208,7 +210,7 @@ Spectrum 2 uses a different custom property prefix. Spectrum 1 overrides will no
208
210
-[ ] Replace `<sp-tabs>` with `<swc-tabs>`, `<sp-tab>` with `<swc-tab>`, `<sp-tab-panel>` with `<swc-tab-panel>`
209
211
-[ ] Rename `value` attribute to `tab-id` on every tab and tab panel
210
212
-[ ] Rename `label` attribute to `accessible-label` on `<swc-tabs>`
211
-
-[ ] Replace boolean `auto` with `keyboard-activation="automatic"`
213
+
-[ ] Replace boolean `auto` with `keyboard-activation`; if you relied on the implicit manual default in Spectrum 1, add `keyboard-activation="manual"` explicitly since Spectrum 2 defaults to `automatic`
212
214
-[ ] Replace boolean `compact` with `density="compact"`
213
215
-[ ] Remove `quiet`, `emphasized`, and `size` attributes
214
216
-[ ] Replace `direction="vertical-right"` with `direction="vertical"`
`keyboard-activation="automatic"`: selection follows focus when arrowing.
85
+
`keyboard-activation="manual"`: arrow keys move focus between tabs without changing the selected tab until Enter or Space. Prefer this when tab panels are expensive to render or not fully present in the DOM.
86
86
87
87
#### Events
88
88
@@ -114,7 +114,7 @@ The `<swc-tabs>` component implements several accessibility features:
114
114
- <kbd>Home</kbd>: moves focus to the first tab
115
115
- <kbd>End</kbd>: moves focus to the last tab
116
116
- <kbd>Space</kbd> / <kbd>Enter</kbd>: activates the focused tab (manual mode).
117
-
In automatic activation, tabs activate when focused via arrows.
117
+
In automatic activation (default), tabs activate when focused via arrows.
Copy file name to clipboardExpand all lines: CONTRIBUTOR-DOCS/03_project-planning/03_components/tabs/accessibility-migration-analysis.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,7 +142,7 @@ This doc describes how `swc-tabs` (with `swc-tab` and `swc-tab-panel`) should be
142
142
|[Focus order (WCAG 2.4.3)](https://www.w3.org/TR/WCAG22/#focus-order)| Tab from the tablist should move to meaningful content (`tabpanel` with `tabindex="0"` when needed, or first focusable in panel) per APG guidance. |
143
143
|[Name, role, value (WCAG 4.1.2)](https://www.w3.org/TR/WCAG22/#name-role-value)| Each tab needs a name; state (`aria-selected`) must update; panels hidden with `hidden` or equivalent must not leave stale state exposed. |
144
144
145
-
**Bottom line:** Choose automatic vs manual activation from real performance and DOM shape; implement APG keyboard tables for the chosen model; keep tab↔panel references valid in the composed tree (see Shadow DOM below).
145
+
**Bottom line:** Choose automatic vs manual activation from real performance and DOM shape; implement APG keyboard tables for the chosen model; keep tab↔panel references valid in the composed tree (see Shadow DOM below). For `swc-tabs`, that resolved to `automatic` as the default (Q20 in migration-plan.md): panel content is always in the light DOM, and matching React Spectrum/React Aria `Tabs` was prioritized once the APG precondition for automatic activation was confirmed to hold.
146
146
147
147
---
148
148
@@ -167,7 +167,7 @@ This doc describes how `swc-tabs` (with `swc-tab` and `swc-tab-panel`) should be
167
167
|**Hidden panels**| Inactive panels use `hidden` (or visibility/display patterns that hide from AT) per APG; do not leave inert content falsely exposed. |
168
168
|**`tabindex` on `tabpanel`**| Per [automatic activation example](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/examples/tabs-automatic/), `tabindex="0"` on `tabpanel` helps users move from tablist into panel content when the first element inside is not focusable. [Manual example](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/examples/tabs-manual/) may omit `tabpanel` tabindex when the first child is focusable — match APG for your story variants. |
169
169
|**Vertical orientation**| If the tablist is vertical, set `aria-orientation="vertical"` and arrow key mapping consistent with APG (Up/Down or Left/Right per spec and docs). |
170
-
|**Activation mode (API)**|Mirror 1st-gen `auto` (boolean, default off = manual): `auto` false — arrows move focus only; Enter, Space, or click select; `auto` true — selection follows focus when arrows move between tabs. Document and test both modes; default manualmatches lazy or heavy panels. |
170
+
|**Activation mode (API)**|Expose both modes via `keyboard-activation`: `manual`— arrows move focus only; Enter, Space, or click select; `automatic`— selection follows focus when arrows move between tabs. Document and test both modes. **Superseded (Q20, see migration-plan.md):**default is `automatic`, not `manual`, to match React Spectrum/React Aria `Tabs` — `swc-tab-panel` content is always in the light DOM (not lazily mounted), so the "default manual matches lazy or heavy panels" reasoning below does not apply to our default; it's retained as guidance for consumers who lazy-render their own panel content. |
-[ ]`tablist` / `tab` / `tabpanel` roles and labelling match APG.
228
-
-[] Automatic vs manual activation documented and tested; default matches content loading model.
228
+
-[x] Automatic vs manual activation documented and tested; default is `automatic` (Q20), matching React Spectrum/React Aria `Tabs` and the component's always-in-DOM panel content.
229
229
-[ ] Roving `tabindex` and arrows use `FocusgroupNavigationController` where appropriate ([#6129](https://github.com/adobe/spectrum-web-components/pull/6129)); tabs-only logic stays in component unless promoted to shared infra deliberately.
230
230
-[ ]`aria-controls` / `aria-labelledby` valid in composed tree (no silent cross-root ID failures).
231
231
-[ ]`tabpanel` focus behavior matches APG for focusable vs non-focusable first content.
0 commit comments