fix(scroll): keyboard-focusable scroll regions + CodeBlock copy/nesting (complex-6/7/8/18)#3369
Merged
Merged
Conversation
…ng (complex-6/7/8/18)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
30 tasks
josephfarina
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the accessibility & keyboard-management program (#3343). Fixes complex-6, complex-7, complex-8, complex-18.
Problem
Several scroll containers in the design system were not reachable by keyboard, and CodeBlock had a nested-interactive ARIA bug:
div role="button"that contained the Copy<button>(invalid nested interactive controls). The Copy button'sonClickalso didn't stop propagation, so clicking Copy collapsed/expanded the block.overflow: auto+maxHeight) had notabIndex, so keyboard users could not scroll long or wide code.TableScrollWrapper(overflow-x: auto) had notabIndex, so a horizontally overflowing table was not keyboard-scrollable.overflow-x: auto) had notabIndex, same problem.Fix
e.stopPropagation()to the Copy button handler so copying no longer toggles collapse. Restructured the header into aheaderRowflex wrapper that holds the sticky/background/padding/divider layout and lays out two siblings: the collapsible title control (role="button") and the Copy button. The Copy button is no longer a DOM descendant of the interactive header. Visual layout (space-between, sticky header, chevron, divider) is preserved.tabIndex={0}+role="region"+ anaria-labelto each overflow container:aria-labelis the language label, or"Code"when no language is shown.TableScrollWrapper—aria-label="Table"(callers can still override role/aria-label viahtmlProps).aria-label="Table".Decision: unconditional
tabIndexThese components do not already have a ref +
ResizeObserverwired up to cheaply detect actual overflow, so I used unconditionaltabIndex={0}on the scroll containers. This matches the findings' explicit ask and keeps the change minimal and consistent across the three components. A future enhancement could maketabIndexconditional on measured overflow (as Base UI's ScrollArea does) to avoid a tab stop when content fits.Note on Markdown table nesting
The Markdown GFM table renders the core
<Table>, whoseTableScrollWrapperis now itself a focusable region. The outer MarkdowntableWrapperdiv still has its ownoverflow-x: auto, so it is treated per the finding for consistency. This does create two nested focusable regions around the same table; flagging for reviewer awareness in case we'd prefer to collapse to a single scroll layer here.Tests
CodeBlock.test.tsx, new file):aria-expandedstaystrue).role="button".tabIndex=0,role="region",aria-label= language or"Code").Table.test.tsx): scroll wrapper is focusable (tabIndex=0,role="region",aria-label="Table").Markdown.test.tsx): GFM table's outer scroll wrapper is focusable (tabIndex=0,role="region",aria-label="Table").Verification
npx tsc --project packages/core/tsconfig.build.json→ exit 0npx eslinton all changed files → clean (exit 0)npx vitest run packages/core/src/CodeBlock packages/core/src/Table packages/core/src/Markdown→ 23 files, 561 tests passedpnpm check:repo→ clean (sync, package boundaries, changesets, demo media)