Skip to content

feat(core): add focus-time scroll keyboard delegation - #6301

Merged
cixzhang merged 2 commits into
meta:mainfrom
jiunshinn:codex/issue-5207-bottomsheet-scroll
Sep 16, 2026
Merged

cixzhang merged 2 commits into
meta:mainfrom
jiunshinn:codex/issue-5207-bottomsheet-scroll

Conversation

@jiunshinn

@jiunshinn jiunshinn commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

User need

Fixes #5207. Keyboard users need to reach every part of overflowing BottomSheet content, including text-only sheets, without an unnecessary viewport stop before a safe existing action.

Problem and solution fit

This prototypes the shared focus-time delegation model discussed in #6301 (comment). useScrollableArea keeps the overflowing viewport named and tabbable, inspects the first sequential descendant on forward Tab entry, and delegates only to a native link or button whose context preserves native scroll keys.

A first input or custom/composite target is never skipped to find a later button. Composite/navigation roles, editable surfaces, popup triggers, positive tab ordering, and native or registered nested scroll owners retain the viewport stop. Shift+Tab from the delegated first child skips the viewport, including after visiting later children. Pointer and programmatic focus remain on the viewport.

Eligibility is recalculated on the next keyboard entry. Keyboard-specific subtree/ancestor observation and the persistent focusability state are removed. Existing geometry observation remains separate, with its original attribute filters. Scrolling stays native.

Current specification

The canonical owners remain spec:AST-025 and module:ScrollableArea/useScrollableArea. Their existing automatic-access records and BottomSheet's draft contract are updated for review; the new head needs owner approval before merging.

Public delta and caller burden

The PR adds the shared contentOrViewport keyboard ownership mode. Existing content and viewport modes remain available. BottomSheet adopts the shared hook without adding public BottomSheet props or exports:

useScrollableArea({
  axis: 'both',
  keyboardAccess: {owner: 'contentOrViewport', label},
  overscroll: 'contain',
  stickyContainment: 'always',
});

The real flow-root content box preserves the existing block/percentage-height layout evidence. Sheet-local Sticky containment stays explicit. Consumers keep their own content names inside the named viewport.

Design and alternatives

Continuous focusability observation was explored earlier on this branch. The prototype replaces that cost with one entry-time eligibility check, using a conservative native link/button boundary. It does not introduce JavaScript scrolling or an additional caller configuration surface.

Evidence

The checked-in Core/BottomSheet → Keyboard Delegation story and BottomSheetKeyboard.a11y.browser.spec.ts cover:

  • Single forward delegation and reverse exit without a viewport/child loop.
  • Excluded controls, composite roles, and nested scroll owners.
  • Native Arrow/Page access to both vertical edges, plus horizontal Arrow scrolling.
  • Pointer/programmatic viewport focus, including focus requested by a Tab handler.
  • Disabled-state and role changes, inserted/removed controls, and next-entry reevaluation with mutation observers disconnected.
  • Accessible names, modal containment, and focused overflow loss.

macOS WebKit's all-controls traversal uses Option+Tab. Its existing non-modal dialog host is a separate native stop, and its native boundary feedback may overshoot an edge. The tests preserve those platform behaviors.

Scope

  • One shared automatic keyboard-access capability, with BottomSheet as its proving composition.
  • Independent ScrollableArea hardening in fix(ScrollableArea): complete hardening audit #6314 remains separate.
  • Consumer docs, focused tests, and compatibility evidence accompany the implementation.
  • Public text and artifacts contain no private operational context.

Testing

  • Focused Vitest coverage: 196 passed across the hook, delegation policy, ScrollableArea, BottomSheet/Panel/Switcher, and consumer-doc checks.
  • Chromium 149 / WebKit 26.5 browser coverage: 48 passed (24 scenarios per engine).
  • pnpm build: passed.
  • pnpm lint:strict: passed with existing warnings and no errors.
  • Core typecheck and pnpm check:knowledge: passed.
  • Full pnpm test --maxWorkers=2: 17,005 passed; the restricted local run also reported 38 failures in 14 tooling suites. Rerunning all failed suites with network/cache access cleared the environment failures. Four unchanged failures remain: two setup-workspace cases requiring GNU cp --reflink on macOS, and two existing Storybook title-classification assertions. None is in the changed scroll/BottomSheet code.

Reproduce the browser proof after pnpm storybook:build and pnpm exec playwright install chromium webkit:

pnpm exec playwright test packages/core/src/BottomSheet/__tests__/BottomSheetKeyboard.a11y.browser.spec.ts

pnpm test:a11y-contract remains scoped to Chromium so the existing CI lane does not start requiring an uninstalled WebKit browser.

@vercel

vercel Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 15, 2026 12:50pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 13, 2026
@astracat-bot

astracat-bot Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Sep 15, 2026, 2:26 PM UTC

@jiunshinn
jiunshinn marked this pull request as ready for review September 13, 2026 02:29
@cixzhang
cixzhang force-pushed the codex/issue-5207-bottomsheet-scroll branch from e189c47 to 9ddecd0 Compare September 13, 2026 13:15
@cixzhang
cixzhang changed the base branch from feat/scrollable-container-system to main September 13, 2026 13:15
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 9ddecd0

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 2bb0fff

@cixzhang
cixzhang force-pushed the codex/issue-5207-bottomsheet-scroll branch from 9ddecd0 to 2bb0fff Compare September 13, 2026 13:19
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review labels Sep 13, 2026
github-actions Bot added a commit that referenced this pull request Sep 13, 2026
@github-actions

github-actions Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

ScrollableArea (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 214 -
Complexity N/A High (20) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB

Accessibility Audit

Status: 36 accessibility violation(s) found — 2 critical, 34 serious.

Button pattern - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/18 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ChatComposer - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/18 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ChatComposerInput - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/14 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ChatReasoning - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 4/5 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ChatToolCalls - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 10/11 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Checkbox pattern - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/33 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
CheckboxList - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 4/17 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ClickableCard - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/5 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
CodeEditor - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/7 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
CodeEditorPerf - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/2 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
CodeEditorTheme - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 13/14 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
CodeTheme - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 14/16 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
DateRangeInput - 1 issue(s)
  • 🔴 critical: Ensure an element's role supports its ARIA attributes
    • Rule: aria-allowed-attr · Affects 1/21 stories · Learn more
    • WCAG: 4.1.2 (Level A)
FileInput - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/15 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
GridMasonry - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/3 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Heading - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/16 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Icon - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/18 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
LogStream - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/3 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
MediaTheme Auto - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/5 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
PowerSearch - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/26 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
ProgressBar - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/18 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Radio group pattern - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/26 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
RadioList - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/13 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
RichTextEditor - 2 issue(s)
  • 🟠 serious: Ensure every ARIA input field has an accessible name
    • Rule: aria-input-field-name · Affects 2/18 stories · Learn more
    • WCAG: 4.1.2 (Level A)
  • 🔴 critical: Ensure every form element has a label
    • Rule: label · Affects 1/18 stories · Learn more
    • WCAG: 4.1.2 (Level A)
SelectableCard - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/4 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Stepper - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/30 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
TableGroupedRows - 1 issue(s)
  • 🟠 serious: Ensure ARIA attributes are used as described in the specification of the element's role
    • Rule: aria-conditional-attr · Affects 3/3 stories · Learn more
    • WCAG: 4.1.2 (Level A)
TableTree - 1 issue(s)
  • 🟠 serious: Ensure ARIA attributes are used as described in the specification of the element's role
    • Rule: aria-conditional-attr · Affects 8/9 stories · Learn more
    • WCAG: 4.1.2 (Level A)
Text - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/23 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Theme - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/5 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
PopArt - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/6 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Thumbnail - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/12 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Timestamp - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/20 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Token - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/10 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Tokenizer - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/24 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Visual Regression

Status: Skipped — Broad stable scope is deferred to the daily release gate. It covers 386 trusted baseline shots instead of recapturing them for this PR. View the report


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang

Copy link
Copy Markdown
Contributor

Sorry—I updated your branch without checking with you first. Your BottomSheet work surfaced a useful system-level question: could useScrollableArea own keyboard-path selection instead of every component implementing it independently?

I explored that direction on this branch, but the continuous observer approach appears too expensive for shared infrastructure. A focus-time, role-aware approach looks more promising.

Would you be interested in pushing on that foundational useScrollableArea behavior with us? Your BottomSheet case is a strong proving ground, and I’d be excited to collaborate on the shared solution.

@jiunshinn

Copy link
Copy Markdown
Contributor Author

@cixzhang No worries about the branch update, and thanks for exploring this! I’d be happy to help develop the shared useScrollableArea behavior and use BottomSheet as a proving ground.
The focus-time, role-aware direction sounds promising. Do you have a particular interaction model in mind? I’d love to understand your thinking and work on an initial implementation.

@cixzhang

Copy link
Copy Markdown
Contributor

Thanks—yes. The interaction model we’re considering is focus-time delegation rather than continuous observation:

  • The overflowing viewport remains the reliable keyboard scroll target with tabIndex=0.
  • On forward Tab entry, useScrollableArea checks the first sequential descendant once. The initial conservative allowlist is native links and buttons only.
  • Do not delegate when that target is inside a composite widget, nested scroll owner, or another surface that owns navigation keys. Radio groups, sliders, text fields, comboboxes, listboxes, menus, grids, trees, tablists, and similar roles keep focus on the viewport.
  • On reverse traversal from the delegated first child, the viewport must be skipped so Shift+Tab exits the scroll area rather than cycling.
  • Pointer and programmatic focus remain on the viewport. Eligibility is recalculated on each keyboard entry; no persistent subtree or ancestor observer.

The browser proof is part of the implementation, not a prerequisite we expect you to already have. The prototype should demonstrate in Chromium and WebKit:

  1. forward Tab delegates once with no duplicate stop;
  2. Shift+Tab exits without a loop;
  3. excluded/composite roles retain the viewport stop;
  4. Arrow/Page keys can still reach the full scroll range after delegation;
  5. pointer/programmatic focus stays on the viewport;
  6. dynamic content is re-evaluated on the next entry without an observer;
  7. accessible naming remains clear in both paths.

Would you be interested in prototyping this in useScrollableArea, with BottomSheet as the proving fixture? We can review the behavior and evidence with you as it develops.

@jiunshinn

Copy link
Copy Markdown
Contributor Author

Thanks, this makes the intended behavior much clearer! I’d be happy to prototype it in useScrollableArea with BottomSheet as the fixture. I’ll start with the conservative link/button allowlist and cover the traversal and scroll behavior in Chromium and WebKit. I’ll share the prototype and browser results for us to review together.

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Sep 15, 2026
@jiunshinn jiunshinn changed the title fix(BottomSheet): restore keyboard access to overflowing content feat(core): add focus-time scroll keyboard delegation Sep 15, 2026
@jiunshinn

Copy link
Copy Markdown
Contributor Author

@cixzhang The prototype is up in b9aa8e1. contentOrViewport now keeps the overflowing viewport tabbable and delegates only on forward keyboard entry to a safe first native link/button. Reverse traversal skips the viewport; pointer and programmatic focus stay on it. Keyboard-eligibility observers/state are removed; the existing geometry observers retain their original filters.

The BottomSheet browser fixture passes 48 checks across Chromium 149 and WebKit 26.5, covering all seven requested behaviors plus modal containment, focused overflow loss, horizontal scrolling, and an excluded first target that must not be skipped. The dynamic-content test disconnects mutation observers before changing eligibility and inserting/removing a control. Native Arrow/Page scrolling reaches the full range after delegation.

The checked-in reproduction is Core/BottomSheet → Keyboard Delegation, with the browser command in the updated PR description. Focused tests (196), build, strict lint, Core typecheck, and knowledge validation pass. The description also records the unrelated local full-suite limitations and their isolated reruns.

AST-025 and the existing module contract are updated for this model, so the new head needs owner approval. I’d appreciate your review of the behavior and the conservative eligibility boundary. The independent hardening changes in #6314 remain separate.

@cixzhang

Copy link
Copy Markdown
Contributor

Thanks—this is a strong, focused prototype. The current head matches the interaction model we outlined: the viewport remains the named stop, forward entry delegates only to a safe first native action, reverse traversal exits without a loop, and pointer/programmatic focus stay on the viewport. The checked-in browser matrix covers the seven requested behaviors in Chromium and WebKit, plus the horizontal and modal cases.

I’m treating the remaining question as owner-level rather than asking you to churn the implementation: this commit also narrows AST-025’s verification matrix from the prior cross-browser requirement to Chromium/WebKit. I’m checking that exact spec change separately. Please hold the current shape while that decision is pending; I’m not asking for branch changes right now.

github-actions Bot added a commit that referenced this pull request Sep 15, 2026
@cixzhang

Copy link
Copy Markdown
Contributor

Owner ruling: accepted.

Chromium + WebKit are sufficient as the checked-in native-keyboard proof matrix for this focus-time delegation behavior. This does not narrow AST-025’s compatibility requirement: useScrollableArea must still work in every browser supported by Astryx Core, including Firefox. The verification row identifies where this interaction receives dedicated native-keyboard browser proof; it is not the browser-support policy.

The current conservative behavior boundary is also accepted: native links/buttons only, excluded composite/navigation-key-owning roles retain the viewport, and BottomSheet remains the proving fixture.

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec b9aa8e1

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Sep 16, 2026

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The focus-time model is strong and the main browser matrix is convincing. I found three bounded issues to fix before merge; none changes the accepted interaction direction.

Comment thread package.json Resolved
@cixzhang
cixzhang dismissed their stale review September 16, 2026 04:26

Owner review determined the remaining observations are rare or trivial and should not block the contributor.

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head b9aa8e1. The focus-time delegation matches the accepted AST-025 direction, the conservative eligibility boundary is appropriate, and the Chromium/WebKit browser evidence covers the user-critical traversal and scrolling behavior.

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Sep 16, 2026
@cixzhang
cixzhang merged commit bfee8a4 into meta:main Sep 16, 2026
49 checks passed
@github-actions
github-actions Bot deleted the codex/issue-5207-bottomsheet-scroll branch September 16, 2026 10:58
AKnassa added a commit to AKnassa/astryx that referenced this pull request Sep 26, 2026
Resolved conflicts:
- packages/core/src/hooks/useScrollableArea.ts: took upstream meta#6301's
  keyboard delegation (hook-scope hasEffectiveAxis, the
  attachScrollKeyboardDelegation layout effect, the `contentOrViewport`
  variant, and the `keyboardAccess.owner !== 'content'` gate with its
  tabIndex ternary). Dropped this branch's keyboardOwner/keyboardLabel/
  keyboardRole scalar extraction, which only handled 'viewport' and would
  have stripped role, aria-label and tabIndex from `contentOrViewport`
  adopters such as BottomSheetPanel. Kept the event-based focus tracking by
  swapping `isViewportFocused` into upstream's keepsProgrammaticFocus, and
  set the getViewportProps deps to keyboardAccess + isViewportFocused
  (no viewport). Extended the ScrollKeyboardAccess JSDoc to cover the new
  variant. (astracat F3)

Merge fallout:
- packages/core/src/hooks/useScrollableArea.test.tsx: removed the
  "keeps prop getter identity stable" test. It locked the dropped scalar
  memoization and the review asked for it to go. (astracat F2, test half)
AKnassa added a commit to AKnassa/astryx that referenced this pull request Sep 26, 2026
… claims

Addresses astracat-bot's review of meta#6314.

F1: ScrollableArea.doc.mjs no longer names `data-scrollable-*` or
`data-scroll-*` as presentation hooks. The declared theming surface stays
the `astryx-scrollable-area` target with `axis`, which theming.targets
already covers, so the whole bestPractices line goes. Stories and tests
that probe those attributes stay because they check behavior. Docs-only,
so there is no red test. Verified with the ScrollableArea suites,
themingTargets.test.ts, check-sync and check-knowledge.

F2: the changeset no longer claims that prop getter identity stays
stable. The identity-locking test and the scalar memoization it guarded
were removed in the upstream merge, since meta#6301's `contentOrViewport`
variant conflicted with them. This removes a guarantee, so there is no
red test.

F3: the retained-tab-stop blur test now runs for both `viewport` and
`contentOrViewport` owners.
Red: against upstream/main's hook, with no event-based focus tracking,
both cases fail at `expect(viewport).not.toHaveAttribute('tabindex')`.
Gating keyboardProps on `owner === 'viewport'`, which is the naive
PR-side merge resolution, fails the contentOrViewport case at
`toHaveAttribute('tabindex', '-1')`.
Green: 22/22 in useScrollableArea.test.tsx. 157/157 across the
useScrollableArea, scrollKeyboardDelegation, ScrollableArea, BottomSheet,
BottomSheetKeyboard and BottomSheetPanel suites.
cixzhang added a commit that referenced this pull request Nov 9, 2026
* fix(ScrollableArea): harden focus and composition

Component Hardening Protocol pass over ScrollableArea and
useScrollableArea (audited against their current contracts):

- getContentProps now consumes caller xstyle instead of leaking it
  to the DOM as an unknown attribute
- viewport focus is tracked with focusin/focusout instead of reading
  document.activeElement during render; a focused viewport that lost
  overflow now drops its retained tab stop once blurred
- prop getter identity stays stable when adopters pass a fresh
  keyboardAccess literal each render
- removed obsolete -webkit-overflow-scrolling and initial-value
  scrollbar-width/gutter declarations, and a dead Omit member
- tests 24 -> 34: padding precedence and published inset asserted by
  atomic class (mutation-verified), vacuous overflow assertions
  tightened, keep-last-state, owner registry unregistration, sideways
  writing modes, content-getter composition, ARIA conflict wins, and
  compiled-CSS read-back for the scrollbar token and scroll-state guard
- stories: NarrowContainer added; RTLBehaviorProbe and
  ConditionalKeyboardAccess plays now assert live edge state and the
  focus-retention path
- docs: hook @example, exported type docs, canonical xstyle wording,
  focus-ring guidance for hook adopters

Part of #6306

* docs(ScrollableArea): clarify region vs group choice

Consumers get one line of guidance on when role="region" is worth a
landmark-navigation entry versus keeping the group default, in both the
full and dense doc surfaces.

Part of #6306

* test(useScrollableArea): kill zero-size guard mutation

The keep-last-state test zeroed only client sizes, so removing the
isMeasurable zero-size guard recomputed a state identical to the
preserved one and survived the suite. Zeroing every metric of the
collapsed box makes an unguarded remeasure publish inactive state,
which the assertion now catches.

Part of #6306

* test(ScrollableArea): assert scroll-state declaration in block

The scroll-state guard test matched only the @supports condition text,
so a mutation of the declaration to container-type: inline-size (with
the condition left intact) passed. Match the declaration inside the
guarded block so a wrong container-type value fails.

Part of #6306

* test(ScrollableArea): anchor CSS read-back to the viewport

Adversarial preflight confirmed two vacuities in the compiled-CSS
tests: the scroll-state assertions were satisfied by the @supports
prelude text alone (a mutated inline-size declaration survived), and
with runtime injection emitting rules for unused styles, neither test
proved the rendered viewport carries the classes (dropping
styles.viewport from the composition stayed green). Both tests now
match the declaration inside its block and require the owning class
on the rendered element.

Also corrects the doc guidance attribute prefixes: effective axes are
data-scrollable-inline/-block, not data-scroll-*.

Part of #6306

* Merge remote-tracking branch 'upstream/main' into rocky/issue-6306-harden-scrollablearea

* Merge upstream/main into rocky/issue-6306-harden-scrollablearea

Resolved conflicts:
- packages/core/src/hooks/useScrollableArea.ts: took upstream #6301's
  keyboard delegation (hook-scope hasEffectiveAxis, the
  attachScrollKeyboardDelegation layout effect, the `contentOrViewport`
  variant, and the `keyboardAccess.owner !== 'content'` gate with its
  tabIndex ternary). Dropped this branch's keyboardOwner/keyboardLabel/
  keyboardRole scalar extraction, which only handled 'viewport' and would
  have stripped role, aria-label and tabIndex from `contentOrViewport`
  adopters such as BottomSheetPanel. Kept the event-based focus tracking by
  swapping `isViewportFocused` into upstream's keepsProgrammaticFocus, and
  set the getViewportProps deps to keyboardAccess + isViewportFocused
  (no viewport). Extended the ScrollKeyboardAccess JSDoc to cover the new
  variant. (astracat F3)

Merge fallout:
- packages/core/src/hooks/useScrollableArea.test.tsx: removed the
  "keeps prop getter identity stable" test. It locked the dropped scalar
  memoization and the review asked for it to go. (astracat F2, test half)

* fix(ScrollableArea): drop unpromised styling-hook and getter-identity claims

Addresses astracat-bot's review of #6314.

F1: ScrollableArea.doc.mjs no longer names `data-scrollable-*` or
`data-scroll-*` as presentation hooks. The declared theming surface stays
the `astryx-scrollable-area` target with `axis`, which theming.targets
already covers, so the whole bestPractices line goes. Stories and tests
that probe those attributes stay because they check behavior. Docs-only,
so there is no red test. Verified with the ScrollableArea suites,
themingTargets.test.ts, check-sync and check-knowledge.

F2: the changeset no longer claims that prop getter identity stays
stable. The identity-locking test and the scalar memoization it guarded
were removed in the upstream merge, since #6301's `contentOrViewport`
variant conflicted with them. This removes a guarantee, so there is no
red test.

F3: the retained-tab-stop blur test now runs for both `viewport` and
`contentOrViewport` owners.
Red: against upstream/main's hook, with no event-based focus tracking,
both cases fail at `expect(viewport).not.toHaveAttribute('tabindex')`.
Gating keyboardProps on `owner === 'viewport'`, which is the naive
PR-side merge resolution, fails the contentOrViewport case at
`toHaveAttribute('tabindex', '-1')`.
Green: 22/22 in useScrollableArea.test.tsx. 157/157 across the
useScrollableArea, scrollKeyboardDelegation, ScrollableArea, BottomSheet,
BottomSheetKeyboard and BottomSheetPanel suites.

* fix(useScrollableArea): track viewport focus in the callback ref

Addresses astracat-bot's review of #6314.

The viewport ref already runs on attach, detach and replacement, and
mergeRefs passes React 19 ref cleanups through. The ref now adopts the
current focus from the viewport's own document, adds focusin and focusout
listeners, and returns a cleanup that removes them and resets the focus
and viewport state. That drops the extra layout effect and its
set-state-in-effect suppression. Reading the owner document keeps a
focused viewport in an iframe focusable when it loses overflow.

Focus events do not always reach the viewport: Chromium fires none while
the page lacks system focus, and an ancestor can stop them. A measurement
that finds no scrollable axis therefore reads focus too. Only a viewport
with no scrollable axis reads that state, so the listeners and the
measurement skip it while an axis scrolls; otherwise each focus change
re-rendered the host, which is costly on lab Schedule's time grid. Until
an axis change is measured, the last measured scrolling keeps a focused
viewport's tabindex, because dropping it in that first commit blurs the
viewport in Chromium.

Tests: the focus lifecycle (StrictMode replay, same-commit replacement,
detach, fresh caller refs, descendants, same-task focus hops, stopped
focus events, axis changes, commit counts while scrolling), padding and
inset variables on every edge, exact scrollbar and overflow values, and
an unmeasurable test that now exercises a full measurement. All 25 hook
mutations are caught. Also reverts a no-op `children` Omit edit, corrects
two story comments, and rewrites the changeset.

Part of #6306

* Merge upstream/main into rocky/issue-6306-harden-scrollablearea

CI's build job checks out the PR head and runs .github/scripts/build-packages-and-storybook.mjs, which landed on main after this branch's base.

* Merge remote-tracking branch 'origin/main' into rocky/issue-6306-harden-scrollablearea

# Conflicts:
#	packages/core/src/hooks/useScrollableArea.test.tsx

* docs(ScrollableArea): the role guidance says to leave role unset rather than restating the default

Co-authored-by: AK <[email protected]>

Co-authored-by: Cindy Zhang <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — b9aa8e1f Deployed Sep 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bottom Sheet: keyboard users cannot scroll the sheet body (axe serious)

2 participants