Repository navigation
fix(www): scroll wide docs tables and label the docs search - #56592
Conversation
There was a problem hiding this comment.
Works as described. With astro dev, every Markdown table is wrapped exactly once: 13/13 on cli/keybinds, 2/2 on build/plugins/migrate-v1, 1/1 on console/api/inference. Tables already wrapped by hand on cli/config (11) and console/models (3) aren't wrapped again. bun typecheck and bun run build pass.
Public API: unchanged (docs site only).
One small point inline: the generated wrappers can't take keyboard focus, unlike the ones wrapped by hand.
| if (isScroller(node)) return | ||
| node.children = node.children?.map((child) => | ||
| child.type === "element" && child.tagName === "table" | ||
| ? { type: "element", tagName: "div", properties: { className: ["docs-table-scroll"] }, children: [child] } |
There was a problem hiding this comment.
The wrappers added by hand (e.g. cli/config.mdx, console/models.mdx) also set role="region", an aria-label and tabIndex={0}, so keyboard users can focus the box and scroll it sideways. These generated wrappers get none of that. In browsers that don't make scroll boxes focusable automatically, a wide table can't be scrolled with the keyboard. Adding tabIndex: 0 here would match the hand-wrapped ones. If you also add role: "region", it needs a label, e.g. one taken from the nearest heading.
Why
On a phone, wide Markdown tables make the whole v2 docs page scroll sideways. At 390px,
cli/keybindsis 716px wide,build/plugins/migrate-v1596px andconsole/api/inference569px, and about ten pages overflow in all. Onlycli/configavoided it, by wrapping each table by hand in<div class="docs-table-scroll">. The search box in the search dialog also has no accessible name, only a placeholder.What Changes
<table>in the existing.docs-table-scrollcontainer (overflow-x: auto), so a wide table scrolls inside its own box instead of widening the page. The wrapper hastabindex="0"so keyboard users can scroll it, like the hand-wrapped ones. Tables already wrapped by hand in MDX are left alone.aria-label="Search docs".Verification
The build passes. On the local dev server,
cli/keybindshas 13 wrappers for 13 tables, andcli/configkeeps exactly 11 wrappers for its 11 hand-wrapped tables, with no double wrapping.