Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(Outline): every link is in the normal Tab order (#9695)

Cindy Zhang9911442c1b6d
diff --git a/.changeset/outline-links-in-tab-order.md b/.changeset/outline-links-in-tab-order.md
new file mode 100644
index 0000000000..04906407f7
--- /dev/null
+++ b/.changeset/outline-links-in-tab-order.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Every `Outline` link is now in the normal Tab order, and Tab moves from link to link, as the Outline record says. Before, the outline was one Tab stop on the current heading, with arrow, Home and End keys moving between links, so a keyboard user who did not know those keys reached only one link. The arrow, Home and End keys no longer move focus between links. (#9001)
+
+@cixzhang @duytbp
diff --git a/apps/storybook/stories/Outline.stories.tsx b/apps/storybook/stories/Outline.stories.tsx
index 1ad3acce78..d3670967d6 100644
--- a/apps/storybook/stories/Outline.stories.tsx
+++ b/apps/storybook/stories/Outline.stories.tsx
@@ -435,9 +435,9 @@ export const NavigateCallbacks: Story = {
};
/**
- * Keyboard navigation. The outline is a single tab stop: Tab moves into it
- * once, then Arrow keys move between headings, Home/End jump to the ends, and
- * Enter or Space activates — a 40-heading TOC costs one Tab press, not 40.
+ * Keyboard navigation. Each link is in the normal Tab order: Tab moves from
+ * link to link and leaves the outline after the last one, and Enter or Space
+ * activates. There is no arrow, Home, or End movement between links.
*/
export const KeyboardNavigation: Story = {
render: () => (
@@ -445,7 +445,7 @@ export const KeyboardNavigation: Story = {
style={{display: 'flex', flexDirection: 'column', gap: 16, width: 240}}>
<button type="button">Focus me, then press Tab</button>
<Outline items={outlineItems} />
- <button type="button">Tab again lands here</button>
+ <button type="button">After the outline</button>
</div>
),
};
diff --git a/docs/specs/components/Outline/Outline.spec.md b/docs/specs/components/Outline/Outline.spec.md
index dd78e5e414..4a6b29a13a 100644
--- a/docs/specs/components/Outline/Outline.spec.md
+++ b/docs/specs/components/Outline/Outline.spec.md
@@ -42,7 +42,7 @@ system_specs: [spec:AST-009, spec:AST-020]
| Behavior | A labelled navigation list of same-page heading links with keyboard movement, a scroll-tracked current heading, and a sliding indicator. |
| End-user impact | People see where they are in a long page and jump to any heading by pointer or keyboard, landing below a fixed header. |
| Builder impact | A builder's explicit `aria-label` is meant to name the navigation; today `label` or the localized default replaces it (FR1 gap). |
-| Compatibility/readiness | Released behavior recorded as current; no API, default, or output changes. Five implementation gaps are listed under Current-state impact. |
+| Compatibility/readiness | Released behavior recorded as current; no API, default, or output changes. Four implementation gaps are listed under Current-state impact. |
| Review checks | Reject a link left out of the Tab order or arrow-key movement added without a named exception, a dead link for a missing target, a callback that fires twice, or a lost focus outline. |
| Governing rules | `architecture:interaction-modality`; `architecture:component-theming-surface`; `architecture:public-component-api` INV5–INV8; `spec:AST-020` FR15; `design:reduced-motion` DR1–DR3; WCAG 2.2 SC 1.3.1, 2.1.1, 2.4.3, 2.4.7. |
@@ -85,11 +85,6 @@ Consumer migration instructions belong in consumer docs and release notes.
and resize transition has no reduced-motion branch, where
`design:reduced-motion` DR1–DR3 have it change at once on a fine pointer and
cross-fade in 200 ms or less on a coarse one.
-- **One roving Tab stop instead of a Tab stop per link (FR3).** Keyboard users
- reach only the current heading's link with Tab and move between links with
- arrow, Home, and End keys, where `spec:AST-020` FR15 keeps a list of
- independently focusable links in the normal Tab order and adds no such keys
- without a named exception. Tests pin today's model.
- **Navigation scrolls smoothly under reduced motion (FR4).** Following a link
always smooth-scrolls to the heading, where `design:reduced-motion` DR1–DR3
have a scroll the component starts land at once on a fine pointer and
@@ -129,7 +124,7 @@ Consumer migration instructions belong in consumer docs and release notes.
| --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| FR1 | Outline renders a `nav` carrying the `outline` target, which reflects `density`, named by `label` or the localized "Table of contents", holding a `ul` (`role="list"`) of `li` items, each with a link to `#<id>` whose label truncates with an ellipsis, then an `aria-hidden` indicator track and an `aria-hidden` active indicator. A caller's explicit `aria-label` reaches the `nav` (`architecture:public-component-api` INV5). Implementation gap: the component's `aria-label` replaces it (Current-state impact). | Current source and tests |
| FR2 | Each link carries the `outline-item` target, which reflects `level` and, for the current heading, `active`; the current link has `aria-current="location"`, primary text color, and semibold weight. Heading levels 1 and 2 share the first indent, and levels 3, 4, and 5–6 take the second, third, and fourth. | Current source and tests |
-| FR3 | Each link is in the normal Tab order, and Outline adds no arrow, Home, or End movement between links unless this record names an exception (`spec:AST-020` FR15); Tab leaves the list after its last link. Implementation gap: today the list is one roving Tab stop, seated on the current heading (the first link when none is current, none when empty) and following it unless focus is inside the list, with ArrowDown and ArrowUp moving real DOM focus between links and Home and End jumping to the first and last (Current-state impact; OQ1). | Current source and tests; `spec:AST-020` FR15; WCAG 2.2 SC 2.1.1 |
+| FR3 | Each link is in the normal Tab order, and Outline adds no arrow, Home, or End movement between links unless this record names an exception (`spec:AST-020` FR15); Tab leaves the list after its last link. | Current source and tests; `spec:AST-020` FR15; WCAG 2.2 SC 2.1.1 |
| FR4 | A click, Enter, or Space on a link whose target exists pushes `#<id>` to history and smoothly scrolls to the heading: at `offset` 0 every scrollable ancestor, the window included, scrolls the heading to the top; with a non-zero `offset` only the scroll root (`scrollContainerRef`, else the nearest scrollable ancestor, else the window) scrolls, landing `offset` pixels plus the heading's own scroll margin below its top; `onNavigateStart` fires when the navigation starts and `onNavigateEnd` exactly once when the scroll settles or the reader interrupts it with a manual scroll, falling back to a timeout when no scroll end arrives; a second navigation ends the first at once, and `onNavigateEnd` does not fire after Outline unmounts mid-scroll. Under reduced motion the navigation scroll does not travel: it lands at once on a fine pointer (`design:reduced-motion` DR3) and cross-fades in 200 ms or less on a coarse pointer (DR2). With `hasScrollOnClick={false}` nothing scrolls: the hash is pushed, the heading marked current, and `onNavigateEnd` fires at once. A click or Enter on a missing target, or any modifier chord, is left to the browser; Space on a missing target does nothing. Following a link moves the sequential focus starting point to the destination, as a native in-page link does (WCAG 2.2 SC 2.4.3). Implementation gaps: the scroll is smooth under reduced motion too; and focus stays on the Outline link, so the next Tab continues after the Outline instead of inside the chosen section (Current-state impact). | Current source and tests |
| FR5 | Uncontrolled, the current heading follows the reader's scroll position in the scroll root (`scrollContainerRef`, else the nearest scrollable ancestor, else the window), using an activation line shifted by `offset` and each heading's own scroll margin; the first heading is current before any heading passes the line, and the last heading is current once the scroll root reaches its end; a click marks its heading current once the scroll settles. Uncontrolled, `onActiveIdChange` reports each change of the current heading, from scroll or a click; controlled, the Outline does not track scroll, `activeId` decides, and `onActiveIdChange` reports the heading a click selects. Keyboard focus movement and the component's own navigation scroll are not treated as manual scrolling. | Current source and tests |
| FR6 | The active indicator is a 2px `--color-icon-primary` bar over a 2px `--color-border` track at the inline start, positioned against the current link with CSS anchor positioning and moving with a fast standard transition. Under reduced motion the indicator does not travel: on a fine pointer it changes at once (`design:reduced-motion` DR3), and on a coarse pointer it cross-fades in 200 ms or less (DR2). Implementation gap: the transition has no reduced-motion branch, so the indicator still slides (Current-state impact). | Current source and tests |
@@ -145,13 +140,13 @@ Consumer migration instructions belong in consumer docs and release notes.
### Representative states
-| State | Required invariant | Allowed variation |
-| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
-| Uncontrolled scrolling | The current heading follows scroll; `onActiveIdChange` reports it. | Offset. |
-| Controlled | `activeId` decides; clicks report through `onActiveIdChange`. | — |
-| Keyboard | Tab visits each link; Enter and Space navigate; no arrow, Home, or End movement (today a single roving stop with them, FR3 gap). | — |
-| Missing target | A click or Enter behaves as a plain link; Space does nothing; no callbacks. | — |
-| Empty | Track and indicator render; no links and so no tab stop. | — |
+| State | Required invariant | Allowed variation |
+| ---------------------- | -------------------------------------------------------------------------------- | ----------------- |
+| Uncontrolled scrolling | The current heading follows scroll; `onActiveIdChange` reports it. | Offset. |
+| Controlled | `activeId` decides; clicks report through `onActiveIdChange`. | — |
+| Keyboard | Tab visits each link; Enter and Space navigate; no arrow, Home, or End movement. | — |
+| Missing target | A click or Enter behaves as a plain link; Space does nothing; no callbacks. | — |
+| Empty | Track and indicator render; no links and so no tab stop. | — |
### Transformation and precedence order
@@ -176,8 +171,7 @@ Consumer migration instructions belong in consumer docs and release notes.
technology.
- **AR3 — Links in Tab order with real focus.** Every link takes keyboard focus
through the normal Tab order and keeps real DOM focus, not
- `aria-activedescendant` (`spec:AST-020` FR15). Implementation gap: today one
- roving Tab stop with arrow, Home, and End keys (FR3).
+ `aria-activedescendant` (`spec:AST-020` FR15).
## Design relationships
@@ -227,7 +221,7 @@ treatment. The Indicator track's target exposure is unsettled (OQ2).
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------ |
| FR1, AR1 | `Outline.test.tsx` labelled-nav, default-label, class, and track tests; stable visual baselines `core-outline--basic` (neutral and probe themes) | Items; default label; track and indicator | A missing `nav` name, link, or indicator, or a lost `outline` class, fails; a changed default outline comes back changed for review. Gap: the track test matches any `aria-hidden` element, so a missing track passes; no test covers the Label wrapper or its truncation, or a caller `aria-label`; and no accessibility-tree check proves the landmark name (`spec:AST-009` FR3). | `audit:Outline/a11y` |
| FR2, AR2 | `Outline.test.tsx` controlled `aria-current`, item class, and active-anchor tests | Controlled current; active ordering | A missing `aria-current`, `outline-item` class, active class, or `data-level`, or an active link after the indicator, fails. Gap: the level indents have no unit check. | `audit:Outline/theming` |
-| FR3, AR3 | `Outline.test.tsx` keyboard suite | One tab stop; real focus; seat on current; follow current; no yank; arrows; Home and End; Tab; one and zero items | More than one tab stop, `aria-activedescendant` use, a tab stop off the current heading, a stop that moves while focus is inside, or a broken arrow, Home, End, or Tab path fails. Known gap: these tests pin today's single roving stop and arrow keys, the FR3 gap, rather than the per-link Tab order FR3 requires; no test covers that order. | `audit:Outline/keyboard` |
+| FR3, AR3 | `Outline.test.tsx` keyboard suite; `OutlineFocus.a11y.chromium.spec.ts` Tab path | Every link in the Tab order; real focus; no arrow, Home, or End movement; Tab out after the last link; one and zero items | A link left out of the Tab order, a `tabindex` on a link, `aria-activedescendant` use, an arrow, Home, or End key that moves focus, or a Tab that stays in the list after its last link fails. | `audit:Outline/keyboard` |
| FR4, ORD2 | `Outline.test.tsx` navigate-callback and scroll-scoping suites | Click, Enter, Space; settle; timeout; double settle; interruption; missing target; modifier; `hasScrollOnClick={false}`; offset landing | A navigation that does not scroll, a callback that fires zero or twice, or a missing target or modifier chord that is intercepted fails. No test covers where focus goes after navigating. No test covers the reduced-motion navigation scroll. No test covers a second navigation ending the first, `onNavigateEnd` not firing after an unmount mid-scroll, or Space on a missing target. No test checks the hash push after a successful navigation. | `audit:Outline/behavior` |
| FR5, ORD1 | `Outline.test.tsx` scroll-tracking, controlled, offset, scroll-margin, and scoped-container tests | Uncontrolled scroll; controlled API; offset; scroll margin; container; keyboard and own scroll | A current heading that ignores the offset or scroll margin, tracks the wrong container, or treats keyboard focus or its own scroll as manual fails. No test dispatches a `scroll` event, so the scroll-event path of tracking has no check. | `audit:Outline/behavior` |
| FR6 | `Outline.test.tsx` indicator tests | Indicator present; active anchor order | A missing indicator fails (a missing track does not; see FR1). Gap: indicator position, size, color, and motion have no automated check beyond the baselines. No test covers the reduced-motion outcome. | `audit:Outline/design` |
@@ -244,10 +238,8 @@ None recorded. The record describes shipped behavior.
- **OQ1 — Should Outline adopt a named `spec:AST-020` FR15 exception: one Tab
stop for a long heading list, with arrow, Home, and End movement?**
- (`human-api`) Adopting it would make today's model the contract: a long
- heading list costs one Tab stop, and keyboard users move inside it with the
- arrow keys, which Tab-only screen reader users may not discover. Without it,
- FR3's per-link Tab order stands and today's model stays the gap.
+ (`human-api`) Without it, a long heading list costs one Tab stop per link
+ (FR3).
- **OQ2 — Should Indicator track gain a stable public theming target?**
(`human-api`) Target exposure is unsettled; the current lack of reachability
does not decide the answer.
diff --git a/packages/core/src/Outline/Outline.doc.mjs b/packages/core/src/Outline/Outline.doc.mjs
index 64a725dfab..de8d5b1f38 100644
--- a/packages/core/src/Outline/Outline.doc.mjs
+++ b/packages/core/src/Outline/Outline.doc.mjs
@@ -63,7 +63,11 @@ export const docs = {
targets: [
{className: 'astryx-outline', visualProps: ['density']},
{className: 'astryx-outline-indicator'},
- {className: 'astryx-outline-item', visualProps: ['level'], states: ['active']},
+ {
+ className: 'astryx-outline-item',
+ visualProps: ['level'],
+ states: ['active'],
+ },
],
},
components: [
@@ -101,7 +105,8 @@ export const docs = {
{
name: 'density',
type: "'default' | 'compact'",
- description: "Density variant controlling item padding. 'compact' for dense UIs, 'default' for standard spacing.",
+ description:
+ "Density variant controlling item padding. 'compact' for dense UIs, 'default' for standard spacing.",
default: "'default'",
},
{
@@ -271,17 +276,53 @@ function FlashOnArrival() {
usage: {
anatomy,
description:
- 'A table-of-contents sidebar for documentation pages, help centers, wikis, and long settings pages. Use it for navigation within a single page, not for app routes. Features a sliding indicator track that animates to the active heading. The list is a single tab stop: arrow keys move between headings, Home/End jump to the ends, and Enter/Space activate.',
+ 'A table-of-contents sidebar for documentation pages, help centers, wikis, and long settings pages. Use it for navigation within a single page, not for app routes. Features a sliding indicator track that animates to the active heading. Each link is in the normal Tab order, and Enter/Space activate.',
bestPractices: [
- {guidance: true, description: 'Pass a flat ordered list of headings and let level control indentation.'},
- {guidance: true, description: 'Use activeId when custom scroll logic owns the active section.'},
- {guidance: true, description: 'Use density="compact" in dense sidebars where vertical space is tight.'},
- {guidance: true, description: 'Use useOutlineFromMarkdown or useOutlineFromDOM when headings are generated from content. For linkable Markdown headings, pass the same createMarkdownHeadingLinks() entry to Markdown and Outline; configure headingIdPrefix on that plugin for multiple roots.'},
- {guidance: true, description: 'Pass scrollContainerRef when the content scrolls in a split pane, modal, or panel instead of the viewport.'},
- {guidance: true, description: 'Set offset to the height of a fixed header that overlays the content, so headings land below it instead of underneath it.'},
- {guidance: false, description: 'Use Outline for application navigation - use SideNav or TopNav for routes.'},
- {guidance: false, description: 'Use Outline for expandable hierarchy - use TreeList when nodes need expand and collapse.'},
- {guidance: false, description: 'Rely on onNavigateEnd to mean "arrived" - it also fires when the user interrupts the scroll.'},
+ {
+ guidance: true,
+ description:
+ 'Pass a flat ordered list of headings and let level control indentation.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use activeId when custom scroll logic owns the active section.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use density="compact" in dense sidebars where vertical space is tight.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use useOutlineFromMarkdown or useOutlineFromDOM when headings are generated from content. For linkable Markdown headings, pass the same createMarkdownHeadingLinks() entry to Markdown and Outline; configure headingIdPrefix on that plugin for multiple roots.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Pass scrollContainerRef when the content scrolls in a split pane, modal, or panel instead of the viewport.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Set offset to the height of a fixed header that overlays the content, so headings land below it instead of underneath it.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use Outline for application navigation - use SideNav or TopNav for routes.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use Outline for expandable hierarchy - use TreeList when nodes need expand and collapse.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Rely on onNavigateEnd to mean "arrived" - it also fires when the user interrupts the scroll.',
+ },
],
},
};
@@ -295,7 +336,11 @@ export const docsZh = {
targets: [
{className: 'astryx-outline', visualProps: ['density']},
{className: 'astryx-outline-indicator'},
- {className: 'astryx-outline-item', visualProps: ['level'], states: ['active']},
+ {
+ className: 'astryx-outline-item',
+ visualProps: ['level'],
+ states: ['active'],
+ },
],
},
components: [
@@ -332,40 +377,47 @@ export const docsZh = {
{
name: 'density',
type: "'default' | 'compact'",
- description: "控制项目内边距的密度变体。'compact' 用于紧凑界面,'default' 为标准间距。",
+ description:
+ "控制项目内边距的密度变体。'compact' 用于紧凑界面,'default' 为标准间距。",
default: "'default'",
},
{
name: 'onNavigateStart',
type: '(id: string) => void',
- description: '导航开始时(滚动前)调用,传入项目 id。与 onNavigateEnd 搭配可在目标标题上实现到达效果(闪烁、描边、脉冲)。',
+ description:
+ '导航开始时(滚动前)调用,传入项目 id。与 onNavigateEnd 搭配可在目标标题上实现到达效果(闪烁、描边、脉冲)。',
},
{
name: 'onNavigateEnd',
type: '(id: string) => void',
- description: '导航结束时调用(平滑滚动停止,或减弱动效将其变为瞬时跳转)。每次 onNavigateStart 必定对应一次调用,包括用户中途手动滚动打断的情况,因此“导航中”状态不会泄漏。',
+ description:
+ '导航结束时调用(平滑滚动停止,或减弱动效将其变为瞬时跳转)。每次 onNavigateStart 必定对应一次调用,包括用户中途手动滚动打断的情况,因此“导航中”状态不会泄漏。',
},
{
name: 'offset',
type: 'number',
- description: '覆盖滚动根顶部的固定顶栏高度(px)。同时位移激活线与滚动落点,因此标题被激活的位置正是点击后停留的位置——落在顶栏下方,而非被顶栏遮住。它与每个标题自身的 scroll-margin-top 叠加(先顶栏,再留白),而非取代它。若没有元素覆盖内容,保持 0,交给 scroll-margin-top 处理。',
+ description:
+ '覆盖滚动根顶部的固定顶栏高度(px)。同时位移激活线与滚动落点,因此标题被激活的位置正是点击后停留的位置——落在顶栏下方,而非被顶栏遮住。它与每个标题自身的 scroll-margin-top 叠加(先顶栏,再留白),而非取代它。若没有元素覆盖内容,保持 0,交给 scroll-margin-top 处理。',
default: '0',
},
{
name: 'scrollContainerRef',
type: 'React.RefObject<HTMLElement | null>',
- description: '要跟踪的滚动容器,替代自动探测最近的可滚动祖先。当内容在分栏、弹窗或面板中滚动而非视口时使用。',
+ description:
+ '要跟踪的滚动容器,替代自动探测最近的可滚动祖先。当内容在分栏、弹窗或面板中滚动而非视口时使用。',
},
{
name: 'hasScrollOnClick',
type: 'boolean',
- description: '激活项目时是否平滑滚动。设为 false 可自行接管滚动(虚拟列表、路由):Outline 仍会更新激活项、hash 和导航回调,但不执行滚动。',
+ description:
+ '激活项目时是否平滑滚动。设为 false 可自行接管滚动(虚拟列表、路由):Outline 仍会更新激活项、hash 和导航回调,但不执行滚动。',
default: 'true',
},
{
name: 'xstyle',
type: 'StyleXStyles',
- description: '用于布局自定义的 StyleX 样式。必须是 stylex.create() 值。',
+ description:
+ '用于布局自定义的 StyleX 样式。必须是 stylex.create() 值。',
},
],
},
@@ -375,12 +427,36 @@ export const docsZh = {
description:
'A table-of-contents sidebar for documentation pages, help centers, wikis, and long settings pages. Use it for navigation within a single page, not for app routes.',
bestPractices: [
- {guidance: true, description: 'Pass a flat ordered list of headings and let level control indentation.'},
- {guidance: true, description: 'Use activeId when custom scroll logic owns the active section.'},
- {guidance: true, description: 'Use density="compact" in dense sidebars where vertical space is tight.'},
- {guidance: true, description: 'Use useOutlineFromMarkdown or useOutlineFromDOM when headings are generated from content. For linkable Markdown headings, pass the same createMarkdownHeadingLinks() entry to Markdown and Outline; configure headingIdPrefix on that plugin for multiple roots.'},
- {guidance: false, description: 'Use Outline for application navigation - use SideNav or TopNav for routes.'},
- {guidance: false, description: 'Use Outline for expandable hierarchy - use TreeList when nodes need expand and collapse.'},
+ {
+ guidance: true,
+ description:
+ 'Pass a flat ordered list of headings and let level control indentation.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use activeId when custom scroll logic owns the active section.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use density="compact" in dense sidebars where vertical space is tight.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use useOutlineFromMarkdown or useOutlineFromDOM when headings are generated from content. For linkable Markdown headings, pass the same createMarkdownHeadingLinks() entry to Markdown and Outline; configure headingIdPrefix on that plugin for multiple roots.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use Outline for application navigation - use SideNav or TopNav for routes.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use Outline for expandable hierarchy - use TreeList when nodes need expand and collapse.',
+ },
],
},
};
@@ -388,34 +464,77 @@ export const docsZh = {
/** @type {import('@astryxdesign/cli/authoring').ComponentTranslationDoc} */
export const docsDense = {
description:
- 'Document outline/table-of-contents nav with sliding indicator track. Flat items array {id,label,level}; anchor links; density variant (default/compact); uncontrolled scroll-spy by scroll position (last heading past its resting line = offset + its own scroll-margin-top; first item at top, last at bottom); controlled with activeId; smooth-scroll on click that pins the active item until the next manual scroll. Single tab stop (roving tabindex): Arrow keys move, Home/End jump, Enter/Space activate. onNavigateStart/onNavigateEnd fire around the scroll. Scroll scoping via offset / scrollContainerRef / hasScrollOnClick.',
+ 'Document outline/table-of-contents nav with sliding indicator track. Flat items array {id,label,level}; anchor links; density variant (default/compact); uncontrolled scroll-spy by scroll position (last heading past its resting line = offset + its own scroll-margin-top; first item at top, last at bottom); controlled with activeId; smooth-scroll on click that pins the active item until the next manual scroll. Each link is a Tab stop; Enter/Space activate; no arrow/Home/End movement. onNavigateStart/onNavigateEnd fire around the scroll. Scroll scoping via offset / scrollContainerRef / hasScrollOnClick.',
usage: {
anatomy,
description:
'A table-of-contents sidebar for documentation pages, help centers, wikis, and long settings pages. Use it for navigation within a single page, not for app routes.',
bestPractices: [
- {guidance: true, description: 'Pass a flat ordered list of headings and let level control indentation.'},
- {guidance: true, description: 'Use activeId when custom scroll logic owns the active section.'},
- {guidance: true, description: 'Use density="compact" in dense sidebars where vertical space is tight.'},
- {guidance: true, description: 'Use useOutlineFromMarkdown or useOutlineFromDOM when headings are generated from content. For linkable Markdown headings, pass the same createMarkdownHeadingLinks() entry to Markdown and Outline; configure headingIdPrefix on that plugin for multiple roots.'},
- {guidance: true, description: 'Pass scrollContainerRef when the content scrolls in a split pane, modal, or panel instead of the viewport.'},
- {guidance: true, description: 'Set offset to the height of a fixed header that overlays the content, so headings land below it instead of underneath it.'},
- {guidance: false, description: 'Use Outline for application navigation - use SideNav or TopNav for routes.'},
- {guidance: false, description: 'Use Outline for expandable hierarchy - use TreeList when nodes need expand and collapse.'},
- {guidance: false, description: 'Rely on onNavigateEnd to mean "arrived" - it also fires when the user interrupts the scroll.'},
+ {
+ guidance: true,
+ description:
+ 'Pass a flat ordered list of headings and let level control indentation.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use activeId when custom scroll logic owns the active section.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use density="compact" in dense sidebars where vertical space is tight.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use useOutlineFromMarkdown or useOutlineFromDOM when headings are generated from content. For linkable Markdown headings, pass the same createMarkdownHeadingLinks() entry to Markdown and Outline; configure headingIdPrefix on that plugin for multiple roots.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Pass scrollContainerRef when the content scrolls in a split pane, modal, or panel instead of the viewport.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Set offset to the height of a fixed header that overlays the content, so headings land below it instead of underneath it.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use Outline for application navigation - use SideNav or TopNav for routes.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Use Outline for expandable hierarchy - use TreeList when nodes need expand and collapse.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Rely on onNavigateEnd to mean "arrived" - it also fires when the user interrupts the scroll.',
+ },
],
},
propDescriptions: {
- items: 'Ordered OutlineItem[]: {id,label,level}. id should match target heading DOM id.',
+ items:
+ 'Ordered OutlineItem[]: {id,label,level}. id should match target heading DOM id.',
activeId: 'Controlled active heading id. Disables built-in scroll-spy.',
onActiveIdChange: 'Called when active id changes from scroll-spy or click.',
label: "Accessible nav label. Default: 'Table of contents'.",
- density: "Density variant: 'default' (standard) or 'compact'. Default: 'default'.",
- onNavigateStart: 'Called with the id when navigation begins, before the scroll.',
- onNavigateEnd: 'Called with the id once the scroll settles. Fires exactly once per onNavigateStart, including on user interruption.',
- offset: 'Height in px of a fixed header overlaying the scroll root. Shifts BOTH the activation line and the scroll landing, so a heading activates where navigating to it lands it. Composes with (does not replace) each heading scroll-margin-top. Default: 0.',
- scrollContainerRef: 'RefObject of the scroll container to track, instead of the nearest scrollable ancestor. For split panes, modals, panels.',
- hasScrollOnClick: 'Whether activating an item smooth-scrolls to it. false = you own scrolling; active id, hash and callbacks still update. Default: true.',
+ density:
+ "Density variant: 'default' (standard) or 'compact'. Default: 'default'.",
+ onNavigateStart:
+ 'Called with the id when navigation begins, before the scroll.',
+ onNavigateEnd:
+ 'Called with the id once the scroll settles. Fires exactly once per onNavigateStart, including on user interruption.',
+ offset:
+ 'Height in px of a fixed header overlaying the scroll root. Shifts BOTH the activation line and the scroll landing, so a heading activates where navigating to it lands it. Composes with (does not replace) each heading scroll-margin-top. Default: 0.',
+ scrollContainerRef:
+ 'RefObject of the scroll container to track, instead of the nearest scrollable ancestor. For split panes, modals, panels.',
+ hasScrollOnClick:
+ 'Whether activating an item smooth-scrolls to it. false = you own scrolling; active id, hash and callbacks still update. Default: true.',
xstyle: 'StyleX styles for layout. Must be stylex.create() value.',
},
components: [
@@ -423,18 +542,25 @@ export const docsDense = {
name: 'Outline',
displayName: 'Outline',
description:
- 'Document outline nav with sliding indicator. Renders heading anchors with a density variant, roving-tabindex keyboard nav, navigate callbacks, and scroll-spy active state when uncontrolled.',
+ 'Document outline nav with sliding indicator. Renders heading anchors with a density variant, links in the normal Tab order, navigate callbacks, and scroll-spy active state when uncontrolled.',
propDescriptions: {
- items: 'Ordered OutlineItem[]: {id,label,level}. id should match target heading DOM id.',
+ items:
+ 'Ordered OutlineItem[]: {id,label,level}. id should match target heading DOM id.',
activeId: 'Controlled active heading id. Disables built-in scroll-spy.',
- onActiveIdChange: 'Called when active id changes from scroll-spy or click.',
+ onActiveIdChange:
+ 'Called when active id changes from scroll-spy or click.',
label: "Accessible nav label. Default: 'Table of contents'.",
density: "Density variant: 'default' | 'compact'. Default: 'default'.",
- onNavigateStart: 'Called with the id when navigation begins, before the scroll.',
- onNavigateEnd: 'Called with the id once the scroll settles. Fires exactly once per onNavigateStart, including on user interruption.',
- offset: 'Height in px of a fixed header overlaying the scroll root. Shifts both the activation line and the scroll landing. Composes with scroll-margin-top. Default: 0.',
- scrollContainerRef: 'RefObject of the scroll container to track, instead of the nearest scrollable ancestor.',
- hasScrollOnClick: 'Whether activating an item smooth-scrolls to it. Default: true.',
+ onNavigateStart:
+ 'Called with the id when navigation begins, before the scroll.',
+ onNavigateEnd:
+ 'Called with the id once the scroll settles. Fires exactly once per onNavigateStart, including on user interruption.',
+ offset:
+ 'Height in px of a fixed header overlaying the scroll root. Shifts both the activation line and the scroll landing. Composes with scroll-margin-top. Default: 0.',
+ scrollContainerRef:
+ 'RefObject of the scroll container to track, instead of the nearest scrollable ancestor.',
+ hasScrollOnClick:
+ 'Whether activating an item smooth-scrolls to it. Default: true.',
xstyle: 'StyleX styles for layout. Must be stylex.create() value.',
},
},
diff --git a/packages/core/src/Outline/Outline.test.tsx b/packages/core/src/Outline/Outline.test.tsx
index 989a1fe7c0..21935e2b13 100644
--- a/packages/core/src/Outline/Outline.test.tsx
+++ b/packages/core/src/Outline/Outline.test.tsx
@@ -344,17 +344,28 @@ describe('Outline keyboard navigation', () => {
vi.restoreAllMocks();
});
- it('exposes a single tab stop (roving tabindex) instead of one per heading', () => {
- render(<Outline items={items} />);
+ it('puts every link in the normal Tab order', async () => {
+ const user = userEvent.setup();
+ render(
+ <>
+ <button type="button">Before</button>
+ <Outline items={items} activeId="api" />
+ </>,
+ );
const links = screen.getAllByRole('link');
-
- // A 40-heading TOC must not cost 40 Tab presses: exactly one link is in
- // the page tab order, the rest are reachable with arrow keys.
expect(links.map(link => link.getAttribute('tabindex'))).toEqual([
- '0',
- '-1',
- '-1',
+ null,
+ null,
+ null,
]);
+
+ screen.getByRole('button', {name: 'Before'}).focus();
+ await user.tab();
+ expect(links[0]).toHaveFocus();
+ await user.tab();
+ expect(links[1]).toHaveFocus();
+ await user.tab();
+ expect(links[2]).toHaveFocus();
});
it('uses actual DOM focus rather than aria-activedescendant', () => {
@@ -372,77 +383,22 @@ describe('Outline keyboard navigation', () => {
expect(links[2]).not.toHaveAttribute('aria-current');
});
- it('seats the tab stop on the active heading, not always the first', () => {
- // WAI-ARIA roving tabindex: the single tab stop belongs on the *current*
- // item. Tabbing into a TOC while reading section 3 must land on section 3,
- // not send the reader back to section 1.
- render(<Outline items={items} activeId="api" />);
- const links = screen.getAllByRole('link');
-
- expect(links.map(link => link.getAttribute('tabindex'))).toEqual([
- '-1',
- '-1',
- '0',
- ]);
- });
-
- it('moves the tab stop as the active heading changes', () => {
- const {rerender} = render(<Outline items={items} activeId="intro" />);
- expect(
- screen.getAllByRole('link').map(l => l.getAttribute('tabindex')),
- ).toEqual(['0', '-1', '-1']);
-
- // Scroll-spy advances the active section: the tab stop must follow it.
- rerender(<Outline items={items} activeId="install" />);
- expect(
- screen.getAllByRole('link').map(l => l.getAttribute('tabindex')),
- ).toEqual(['-1', '0', '-1']);
- });
-
- it('does not yank the tab stop away from the item the user arrowed to', async () => {
+ it('adds no arrow, Home, or End movement between links', async () => {
const user = userEvent.setup();
- const {rerender} = render(<Outline items={items} activeId="intro" />);
+ render(<Outline items={items} />);
const links = screen.getAllByRole('link');
- // User arrow-keys down to `api` and keeps focus there.
links[0].focus();
- await user.keyboard('{ArrowDown}{ArrowDown}');
- expect(links[2]).toHaveFocus();
- expect(links[2]).toHaveAttribute('tabindex', '0');
-
- // Scroll-spy moves the active section underneath them. Focus is still
- // inside the list, so the tab stop must stay where the user put it.
- rerender(<Outline items={items} activeId="install" />);
- expect(links[2]).toHaveAttribute('tabindex', '0');
- expect(links[1]).toHaveAttribute('tabindex', '-1');
- });
-
- it('moves focus with ArrowDown / ArrowUp', async () => {
- const user = userEvent.setup();
- render(<Outline items={items} />);
- const [intro, install] = screen.getAllByRole('link');
-
- intro.focus();
await user.keyboard('{ArrowDown}');
- expect(install).toHaveFocus();
- expect(install).toHaveAttribute('tabindex', '0');
- expect(intro).toHaveAttribute('tabindex', '-1');
+ expect(links[0]).toHaveFocus();
+ await user.keyboard('{End}');
+ expect(links[0]).toHaveFocus();
+ links[2].focus();
await user.keyboard('{ArrowUp}');
- expect(intro).toHaveFocus();
- });
-
- it('jumps to first / last with Home / End', async () => {
- const user = userEvent.setup();
- render(<Outline items={items} />);
- const links = screen.getAllByRole('link');
-
- links[0].focus();
- await user.keyboard('{End}');
expect(links[2]).toHaveFocus();
-
await user.keyboard('{Home}');
- expect(links[0]).toHaveFocus();
+ expect(links[2]).toHaveFocus();
});
it('activates the focused link with Space', async () => {
@@ -517,7 +473,7 @@ describe('Outline keyboard navigation', () => {
cleanup();
});
- it('does not treat arrow-key roving focus as a manual scroll', async () => {
+ it('does not treat Tab between links as a manual scroll', async () => {
const user = userEvent.setup();
const cleanup = mountHeadings();
const onNavigateEnd = vi.fn();
@@ -525,17 +481,16 @@ describe('Outline keyboard navigation', () => {
render(<Outline items={items} onNavigateEnd={onNavigateEnd} />);
await user.click(screen.getByRole('link', {name: 'Installation'}));
- // Following the link focuses the section; return to the outline. Arrow
- // keys inside it move focus; they are prevented, so they do not scroll
- // the page and must not cancel the in-flight navigation.
+ // Tab moves focus and does not scroll the page, so it must not end the
+ // navigation that the click started.
screen.getByRole('link', {name: 'Installation'}).focus();
- await user.keyboard('{ArrowDown}');
+ await user.tab();
expect(onNavigateEnd).not.toHaveBeenCalled();
cleanup();
});
- it('does not steal Tab from the page', async () => {
+ it('leaves the list with Tab after its last link', async () => {
const user = userEvent.setup();
render(
<>
@@ -544,18 +499,17 @@ describe('Outline keyboard navigation', () => {
</>,
);
- screen.getAllByRole('link')[0].focus();
+ screen.getAllByRole('link')[2].focus();
await user.tab();
- // The non-tabbable links are skipped, so one Tab leaves the whole outline.
expect(screen.getByRole('button', {name: 'After'})).toHaveFocus();
});
- it('keeps a single tab stop with one item, and none with zero items', () => {
+ it('keeps one link in the Tab order with one item, and none with zero items', () => {
const {rerender} = render(
<Outline items={[{id: 'only', label: 'Only', level: 2}]} />,
);
- expect(screen.getAllByRole('link')[0]).toHaveAttribute('tabindex', '0');
+ expect(screen.getAllByRole('link')[0]).not.toHaveAttribute('tabindex');
rerender(<Outline items={[]} />);
expect(screen.queryAllByRole('link')).toHaveLength(0);
diff --git a/packages/core/src/Outline/Outline.tsx b/packages/core/src/Outline/Outline.tsx
index bcdc5aaee8..70646fea84 100644
--- a/packages/core/src/Outline/Outline.tsx
+++ b/packages/core/src/Outline/Outline.tsx
@@ -4,7 +4,7 @@
/**
* @file Outline.tsx
- * @input Uses React, StyleX, Astryx link provider integration, Outline hooks/types, useListFocus
+ * @input Uses React, StyleX, Astryx link provider integration, Outline hooks/types
* @output Exports Outline component and OutlineProps type
* @position Core implementation; consumed by index.ts
*
@@ -12,7 +12,7 @@
* - Sliding indicator track (vertical divider + animated active bar)
* - Density variant (default/compact)
* - Scroll-spy active state when uncontrolled
- * - Roving-tabindex keyboard navigation (Arrow/Home/End, Enter/Space activate)
+ * - Each link in the normal Tab order (Enter/Space activate)
* - onNavigateStart / onNavigateEnd callbacks around the smooth scroll
* - Scroll scoping (offset, scrollContainerRef, hasScrollOnClick)
*
@@ -35,8 +35,6 @@ import {
fontWeightVars,
} from '../theme/tokens.stylex';
import {useLinkComponent} from '../Link/useLinkComponent';
-import {useListFocus} from '../hooks/useListFocus';
-import {useIsomorphicLayoutEffect} from '../hooks/useIsomorphicLayoutEffect';
import {mergeProps} from '../utils';
import type {BaseProps} from '../BaseProps';
import {useScrollSpy} from './useScrollSpy';
@@ -304,10 +302,8 @@ function moveFocusTo(id: string) {
* scroll root) plus the heading's own `scroll-margin-top`. It defaults to the
* first item at the top and the last at the bottom.
*
- * Keyboard: the list is a single tab stop (roving tabindex), seated on the
- * active heading. Arrow keys move between headings, Home/End jump to the ends,
- * and Enter/Space activate — so a long table of contents costs one Tab press,
- * not one per heading.
+ * Keyboard: each link is in the normal Tab order, and Enter/Space activate.
+ * There is no arrow, Home, or End movement between links.
*
* @example
* ```
@@ -369,49 +365,6 @@ export function Outline({
onNavigateEnd,
});
- // Roving tabindex over the links: the whole outline is one tab stop, and
- // arrows move between headings. The hook owns `tabindex` on the items.
- const {
- listRef,
- handleKeyDown: handleListKeyDown,
- handleFocus,
- } = useListFocus<HTMLUListElement>({
- itemSelector: 'a[href]',
- orientation: 'vertical',
- hasRovingTabIndex: true,
- });
-
- // Seat the tab stop on the *active* heading. WAI-ARIA puts the single tab
- // stop on the current item, so tabbing into a table of contents while
- // reading section 7 lands on section 7 — not back at section 1, which is
- // where useListFocus would otherwise leave it (it promotes the first item on
- // mount and then keeps whichever item already holds the stop).
- //
- // Only while focus is outside the list: once the reader has arrowed to an
- // item, the stop is theirs and scroll-spy must not yank it away. Sets
- // `tabindex` only — it never steals focus. Registered after useListFocus so
- // it runs after the hook's own layout effect and wins; on later commits the
- // hook then finds this item already holding the stop and keeps it.
- useIsomorphicLayoutEffect(() => {
- const list = listRef.current;
- if (list == null || list.contains(document.activeElement)) {
- return;
- }
- const links = Array.from(list.querySelectorAll<HTMLElement>('a[href]'));
- const active = links.find(
- link => link.getAttribute('aria-current') === 'location',
- );
- if (active == null) {
- return;
- }
- for (const link of links) {
- const tabIndex = link === active ? '0' : '-1';
- if (link.getAttribute('tabindex') !== tabIndex) {
- link.setAttribute('tabindex', tabIndex);
- }
- }
- });
-
/**
* The single navigation path, shared by click and keyboard activation:
* push the hash, then hand off to the scroll-spy's `scrollTo`, which fires
@@ -480,12 +433,7 @@ export function Outline({
className,
style,
)}>
- <ul
- {...stylex.props(styles.list)}
- ref={listRef}
- role="list"
- onKeyDown={handleListKeyDown}
- onFocus={handleFocus}>
+ <ul {...stylex.props(styles.list)} role="list">
{items.map(item => {
const isActive = item.id === resolvedActiveId;
diff --git a/packages/core/src/Outline/OutlineFocus.a11y.chromium.spec.ts b/packages/core/src/Outline/OutlineFocus.a11y.chromium.spec.ts
index bf22e71d03..9b69d79419 100644
--- a/packages/core/src/Outline/OutlineFocus.a11y.chromium.spec.ts
+++ b/packages/core/src/Outline/OutlineFocus.a11y.chromium.spec.ts
@@ -62,11 +62,11 @@ interface Receipt {
readonly browser: string;
readonly build: string;
readonly focused: FocusPaint;
- readonly arrowed: FocusPaint;
+ readonly tabbedNext: FocusPaint;
readonly pointerFocusVisible: boolean;
readonly touchFocusVisible: boolean | null;
readonly restToFocusChangedPixels: number;
- readonly restToArrowChangedPixels: number;
+ readonly restToNextChangedPixels: number;
readonly screenshots: ReadonlyArray<string>;
readonly video: string;
}
@@ -74,16 +74,30 @@ interface Receipt {
let storybook: StaticServer;
const receipts: Receipt[] = [];
let checkoutSha = '';
+
+/**
+ * Whether the checkout is the PR head itself, or the merge commit CI checks
+ * out for a pull request: a commit with two parents, one of them the PR head.
+ * The raw commit object lists its parents even in a shallow clone.
+ */
+function checksOutHead(checkoutSha: string, headSha: string): boolean {
+ if (checkoutSha === headSha) {
+ return true;
+ }
+ const commit = execFileSync('git', ['cat-file', '-p', checkoutSha], {
+ encoding: 'utf8',
+ });
+ const parents = commit.split('\n').filter(line => line.startsWith('parent '));
+ return parents.length >= 2 && parents.includes(`parent ${headSha}`);
+}
let storybookSha = '';
test.beforeAll(async () => {
checkoutSha = execFileSync('git', ['rev-parse', 'HEAD'], {
encoding: 'utf8',
}).trim();
- if (
- process.env.ASTRYX_HEAD_SHA &&
- process.env.ASTRYX_HEAD_SHA !== checkoutSha
- ) {
+ const reviewedHead = process.env.ASTRYX_HEAD_SHA;
+ if (reviewedHead && !checksOutHead(checkoutSha, reviewedHead)) {
throw new Error('The audited checkout does not match the PR head');
}
fs.mkdirSync(OUTPUT, {recursive: true});
@@ -97,7 +111,9 @@ test.beforeAll(async () => {
);
}
storybookSha = (await stamp.text()).trim();
- if (storybookSha !== checkoutSha) {
+ // A pull request's Storybook is stamped with the PR head, while CI checks
+ // out that head's merge commit.
+ if (storybookSha !== checkoutSha && storybookSha !== reviewedHead) {
throw new Error(
'The served Storybook build does not match the audited checkout',
);
@@ -118,7 +134,7 @@ test.afterAll(async () => {
selected: 'Outline exposes current location, not selection',
disabled: 'OutlineItem has no disabled state',
ariaActiveDescendant:
- 'Outline uses actual DOM focus with roving tabindex instead',
+ 'Outline uses actual DOM focus; each link is its own Tab stop',
},
receipts,
},
@@ -372,7 +388,7 @@ async function runScenario(
const screenshots = {
rest: path.join(OUTPUT, `${prefix}__rest.png`),
focus: path.join(OUTPUT, `${prefix}__focus.png`),
- arrow: path.join(OUTPUT, `${prefix}__arrow.png`),
+ next: path.join(OUTPUT, `${prefix}__next.png`),
pointer: path.join(OUTPUT, `${prefix}__pointer.png`),
};
const videoPath = path.join(OUTPUT, `${prefix}.webm`);
@@ -402,7 +418,9 @@ async function runScenario(
),
);
expect(currentIndex).toBeGreaterThanOrEqual(0);
- const nextIndex = (currentIndex + 1) % 6;
+ const linkTexts = await links.evaluateAll(elements =>
+ elements.map(element => element.textContent?.trim() ?? ''),
+ );
if (scenario.pageScaleFactor != null) {
const cdp = await page.context().newCDPSession(page);
@@ -423,23 +441,21 @@ async function runScenario(
const focusedPng = await screenshotRegion(page);
fs.writeFileSync(screenshots.focus, focusedPng);
- await page.keyboard.press('ArrowDown');
- const arrowed = await focusPaint(page);
- const arrowPng = await screenshotRegion(page);
- fs.writeFileSync(screenshots.arrow, arrowPng);
-
- const prior = await links.nth(currentIndex).getAttribute('tabindex');
- const current = await links.nth(nextIndex).getAttribute('tabindex');
- expect(prior).toBe('-1');
- expect(current).toBe('0');
+ // Each link is its own Tab stop: the next Tab reaches the second link.
+ await page.keyboard.press('Tab');
+ const tabbedNext = await focusPaint(page);
+ const nextPng = await screenshotRegion(page);
+ fs.writeFileSync(screenshots.next, nextPng);
+ await expect(links.nth(1)).toBeFocused();
- // Focus return uses the roving stop the reader last chose, not the old current item.
+ // Shift+Tab goes back one link; Tab from the last link leaves the list.
await page.keyboard.press('Shift+Tab');
+ await expect(links.nth(0)).toBeFocused();
+ await links.nth(5).focus();
+ await page.keyboard.press('Tab');
await expect(
- page.getByRole('button', {name: 'Focus me, then press Tab'}),
+ page.getByRole('button', {name: 'After the outline'}),
).toBeFocused();
- await page.keyboard.press('Tab');
- await expect(links.nth(nextIndex)).toBeFocused();
// Programmatic focus uses the same actual-DOM-focus model;
// aria-activedescendant is intentionally absent.
@@ -492,30 +508,30 @@ async function runScenario(
browser: browser.version(),
build: target.name === 'current-head' ? storybookSha : 'external-preview',
focused,
- arrowed,
+ tabbedNext,
pointerFocusVisible,
touchFocusVisible,
restToFocusChangedPixels: changedPixels(rest, focusedPng),
- restToArrowChangedPixels: changedPixels(rest, arrowPng),
+ restToNextChangedPixels: changedPixels(rest, nextPng),
screenshots: Object.values(screenshots).map(file => path.basename(file)),
video: path.basename(videoPath),
};
const checks = () => {
expectVisibleTokenRing(focused);
- expect(focused.ariaCurrent).toBe('location');
- expect(focused.tabIndex).toBe('0');
+ expect(focused.text).toBe(linkTexts[0]);
+ expect(focused.tabIndex).toBeNull();
expect(focused.level).toMatch(/^[1-6]$/);
- expectVisibleTokenRing(arrowed);
- expect(arrowed.ariaCurrent).toBeNull();
- expect(arrowed.tabIndex).toBe('0');
- expect(arrowed.level).toMatch(/^[1-6]$/);
+ expectVisibleTokenRing(tabbedNext);
+ expect(tabbedNext.text).toBe(linkTexts[1]);
+ expect(tabbedNext.tabIndex).toBeNull();
+ expect(tabbedNext.level).toMatch(/^[1-6]$/);
expect(receipt?.pointerFocusVisible).toBe(false);
expect(receipt?.touchFocusVisible).not.toBe(true);
expect(receipt?.restToFocusChangedPixels).toBeGreaterThan(0);
- expect(receipt?.restToArrowChangedPixels).toBeGreaterThan(0);
+ expect(receipt?.restToNextChangedPixels).toBeGreaterThan(0);
};
try {
checks();
diff --git a/packages/core/src/Outline/useScrollSpy.ts b/packages/core/src/Outline/useScrollSpy.ts
index d71d78822b..bb8606f28a 100644
--- a/packages/core/src/Outline/useScrollSpy.ts
+++ b/packages/core/src/Outline/useScrollSpy.ts
@@ -410,9 +410,9 @@ export function useScrollSpy({
const onSettle = () => finish(true);
const onManual = () => finish(false);
const onKeyDown = (event: KeyboardEvent) => {
- // A key the outline itself consumed (arrow roving focus, Space
- // activation) is prevented, so the browser will not scroll — it is not a
- // manual scroll intent and must not cancel the navigation it just began.
+ // The outline prevents the Space key that activates a link. The
+ // browser then does not scroll. So this key is not a manual scroll, and
+ // it does not end the navigation.
if (!event.defaultPrevented && SCROLL_KEYS.has(event.key)) {
finish(false);
}