Skip to content

Commit 5dff20a

Browse files
committed
fix(docs): give API samples one keyboard entry
1 parent 9c17042 commit 5dff20a

4 files changed

Lines changed: 16 additions & 37 deletions

File tree

‎apps/docs/components/docs/sample-panels.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,13 @@ export function SamplePanels({
8686
value={item.value}
8787
label={item.label}
8888
id={item.id ?? `${selectorId}-${item.value}`}
89+
tabIndex={-1}
8990
{...(presentation === 'select' ? { role: 'region', 'aria-labelledby': selectorId } : {})}
9091
className='[&>div]:pt-0'
9192
>
92-
<CodeContent label={`${label}: ${item.label}`}>{item.panel}</CodeContent>
93+
<CodeContent label={`${label}: ${item.label}`} tabIndex={0}>
94+
{item.panel}
95+
</CodeContent>
9396
</Tab>
9497
))}
9598
</Tabs>

‎apps/docs/components/ui/code-block.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ interface CodeBlockProps extends HTMLAttributes<HTMLElement> {
1818
interface CodeContentProps {
1919
children: ReactNode
2020
label?: string
21+
tabIndex?: number
2122
}
2223

23-
export function CodeContent({ children, label = 'Code sample' }: CodeContentProps) {
24+
export function CodeContent({ children, label = 'Code sample', tabIndex }: CodeContentProps) {
2425
return (
2526
<ScrollRegion
2627
label={label}
28+
tabIndex={tabIndex}
2729
className='focus-visible:-outline-offset-2 p-4 [&_code]:block [&_code]:bg-transparent [&_code]:p-0 [&_code]:font-normal [&_code]:text-docs-code [&_pre]:m-0 [&_pre]:w-max [&_pre]:min-w-full [&_pre]:bg-transparent! [&_pre]:p-0 [&_pre]:font-mono [&_pre]:text-docs-code [&_pre]:[font-variant-ligatures:none]'
2830
>
2931
{children}

‎apps/docs/components/ui/scroll-region.tsx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@ interface ScrollRegionProps extends HTMLAttributes<HTMLDivElement> {
88
label: string
99
}
1010

11-
/** Keeps scrolling keyboard-accessible before hydration, then skips regions without overflow. */
11+
/** Keeps scrolling keyboard-accessible before hydration, then skips nonoverflowing regions unless opted in. */
1212
export function ScrollRegion({
1313
label,
1414
className,
1515
children,
16-
tabIndex = 0,
16+
tabIndex,
1717
...props
1818
}: ScrollRegionProps) {
1919
const region = useRef<HTMLDivElement>(null)
2020
useEffect(() => {
2121
const element = region.current
2222
if (!element) return
2323
function updateFocusability() {
24-
if (element) element.tabIndex = element.scrollWidth > element.clientWidth + 1 ? tabIndex : -1
24+
if (element)
25+
element.tabIndex = tabIndex ?? (element.scrollWidth > element.clientWidth + 1 ? 0 : -1)
2526
}
2627
const observer = new ResizeObserver(updateFocusability)
2728
observer.observe(element)
@@ -32,7 +33,7 @@ export function ScrollRegion({
3233
<div
3334
{...props}
3435
ref={region}
35-
tabIndex={tabIndex}
36+
tabIndex={tabIndex ?? 0}
3637
role='region'
3738
aria-label={label}
3839
className={cn(

‎apps/docs/scripts/fixtures/content-baseline.json‎

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18851,42 +18851,15 @@
1885118851
"media": [
1885218852
{
1885318853
"type": "Image",
18854-
"src": "/static/docs-captures/files-formatting.webp",
18855-
"alt": "Selected text in the Markdown editor with the text style, bold, italic, link, and more formatting controls",
18854+
"src": "/static/docs-captures/files-markdown.webp",
18855+
"alt": "A release brief open in the Markdown editor beside Chat, with a launch checklist, owner table, and highlighted JSON code block",
1885618856
"width": {
18857-
"expression": "900"
18857+
"expression": "2400"
1885818858
},
1885918859
"height": {
18860-
"expression": "340"
18861-
},
18862-
"variant": "detail",
18863-
"background": "architecture"
18864-
},
18865-
{
18866-
"type": "Image",
18867-
"src": "/static/docs-captures/files-table.webp",
18868-
"alt": "A Markdown owner table with controls for adding a row, managing columns, and deleting the table",
18869-
"width": {
1887018860
"expression": "1200"
1887118861
},
18872-
"height": {
18873-
"expression": "460"
18874-
},
18875-
"variant": "detail",
18876-
"background": "architecture"
18877-
},
18878-
{
18879-
"type": "Image",
18880-
"src": "/static/docs-captures/files-code.webp",
18881-
"alt": "A highlighted JSON code block with language, line wrap, and copy controls",
18882-
"width": {
18883-
"expression": "1200"
18884-
},
18885-
"height": {
18886-
"expression": "400"
18887-
},
18888-
"variant": "detail",
18889-
"background": "architecture"
18862+
"variant": "overview"
1889018863
}
1889118864
]
1889218865
},

0 commit comments

Comments
 (0)