Skip to content

fix(Table): the scroll wrapper and tree toggles draw the shared focus ring - #8873

Merged
cixzhang merged 10 commits into
mainfrom
lane4/focus-ring-table
Nov 7, 2026
Merged

cixzhang merged 10 commits into
mainfrom
lane4/focus-ring-table

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Part of #8852 (the Table half; CodeBlock and Carousel, and ChatMessageList, Tooltip and HoverCard follow as their own PRs)

Corners

A bordered Card's rounded corner still trims the ring's corners. That is addressed separately by the container corner-radius work (containers share their radius with full-bleed children).

User impact

A keyboard user tabbing through a Table meets three tab stops that ignore the app's theme. The browser draws its own default focus ring on them: the scroll wrapper once the table scrolls inline, and the tree plugin's row expander and expand-all toggle. That ring has its own colour, width and style, looks different in each browser, and inside a Card it's partly cut off at the card's edge, so the focused element is hard to see. After this change each of them draws the same theme-driven ring as every other Astryx control, whole.

Problem and solution fit

  • Why the browser's ring? These three elements take keyboard focus but carry no ring style, so they fall back to the user-agent default (WCAG 2.4.7 needs a visible focus indicator, and the theme's --focus-outline-* tokens are how Astryx draws one).
  • Why is it cut off in a Card? The wrapper bleeds to its container's edges, and Card clips (overflow: clip), so a ring drawn around the wrapper falls outside the clip.
  • Why does it matter? A theme that restyles the ring (colour, width) reached every other control but not these.

The fix composes the shared ring (focusOutlineStyles.focusVisible / focusOutlineProps.focusVisible) on all three. On the wrapper only, the ring is inset by its own width plus the border width, so it stays clear of a bordered Card's border and inside the clip. At density="compact" the tree toggles' ring is inset by its width, so the cell's overflow: hidden does not cut it.

Expected behavior and authority

Smallest restoration

  • Table.tsx: the scroll wrapper composes the shared ring plus an inset offset (calc(-1 * (--focus-outline-width + --border-width))).
  • useTableTreeData.tsx: the row expander and the expand-all toggle compose the shared ring through focusOutlineProps.focusVisible.
  • No new prop, token, or default.

Evidence

Real Chrome 156 (headless, DPR 2), Storybook from main and from this branch. Focus was reached by real Tab presses, so :focus-visible matches. Computed outline on the focused element, and whether its painted ring fits inside the nearest clipping ancestor:

Tab stop (story) Width main This PR
Scroll wrapper (Table · Responsive scroll in card) 1280, 390 auto 1px UA ring; cut off by the Card solid 2px theme colour, offset -3px; edges whole (a Card's rounded corners trim the square corners)
Tree row expander (TableTree · Header expand-all control) 1280, 390 auto 1px UA ring solid 2px theme colour, offset 3px; whole
Expand-all toggle (same story) 1280, 390 auto 1px UA ring solid 2px theme colour, offset 3px; whole
  • Regression tests: Table.focusRing.test.tsx, 3 cases, all failing on main; TableFocusRing.a11y.chromium.spec.ts, 2 cases, failing on main and passing on this PR's Vercel Storybook (the Card wrapper and the compact tree toggles paint a solid ring whose straight edges no clipping ancestor cuts; the check compares rectangles and does not see the Card's corner radius, so it does not cover the clipped corners noted above). Each tab stop carries the classes the shared ring compiles to, and the wrapper also carries the inset. jsdom doesn't match :focus-visible, so the geometry is the browser check above.
  • Representative unchanged path: the Table suites, 649 tests. The three perf-budget tests time out on this heavily loaded machine on main too.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm vitest run packages/core/src/Table: 649 pass, with the new tests failing first.
  • tsc --noEmit for core, eslint, prettier.
  • The real-Chrome probe above, desktop and 390 px.

Chromium evidence

TableFocusRing.a11y.chromium.spec.ts passes 2 of 2 against this head's exact Vercel Storybook (1ce8da1). The compact tree toggles paint a solid ring that no clipping ancestor cuts. The bordered-Card scroll wrapper's ring has whole straight edges, but its corners are clipped by the Card's rounded corner (see Corners above). On main all three stops fail: the ring is the browser's auto outline, and the CompactDensity story does not exist there.

@vercel

vercel Bot commented Oct 28, 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 Nov 7, 2026 4:07pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 7, 2026, 4:15 PM UTC

@astracat-bot astracat-bot Bot 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.

Thanks: the shared focus ring now reaches the scroll wrapper and both tree toggles, and a scrolling table inside a Card shows a focus ring for the first time. A few things need to change before this merges:

  • In a bordered Card the wrapper's ring is still clipped by 1px on every side, because the wrapper bleeds under the Card's border (Card draws its border inside its padding), so an inset of one ring width is not enough.
  • At density="compact" the tree toggles' ring loses its top and bottom pixel to the cell's overflow: hidden.
  • The changeset says all of Table's tab stops now draw the theme ring, but the row-expansion, grouped-rows and filter buttons still draw the browser's ring; please name the three this PR covers and fix the Card sentence.
  • The new test compares compiled class names, so it cannot see the ring; a Chromium spec that tabs to each stop and checks the computed outline and its fit inside the clip (as OutlineFocus.a11y.chromium.spec.ts does) would protect the fix.

[Automated review]

Comment thread packages/core/src/Table/Table.tsx Resolved
Comment thread .changeset/table-focus-ring.md Resolved
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 31, 2026
@cixzhang
cixzhang marked this pull request as draft October 31, 2026 18:08

@humbertovirtudes humbertovirtudes 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.

Requesting changes on exact head 4d4f93bd311333b4917f89500b193cba5e8d9b38 for the Table-related delta and its direct dependencies. This is not a rejection of unrelated work in the PR.

  1. [MAJOR] packages/core/src/Table/Table.tsx:142

The new inset clears only the outline width, not the bordered Card's existing bleed beyond its clip edge.

Failure case: Card applies each padding inset as the published container padding minus border width, while Table's wrapper bleeds by the full published inset. With the default 1px border the wrapper extends 1px beyond the Card padding edge. The 2px outline at offset -2px has its outer edge on that wrapper boundary, so the source geometry still places part of the indicator outside the clip.

Requested fix: Fit the ring to the actual clipping boundary, preserving the shared width/style/colour and existing layout. Account for the border overshoot or choose an existing unclipped paint owner. Verify matched bordered/borderless Card, theme border widths, narrow/desktop and both directions in the canonical Table browser/visual fixture; correct the unconditional Card release claim.

  1. [MAJOR] packages/core/src/Table/plugins/tree/useTableTreeData.tsx:330

The newly added outward shared ring exceeds compact cells' clipping allowance for both tree toggles.

Failure case: Each toggle is 24px high. Compact body/header cells have --spacing-1 block padding (0.25rem, 4px at the standard 16px root), and both wrap/truncate/header paths use overflow:hidden. The default outline extends 3px offset + 2px width = 5px beyond the button. This exceeds the compact padding by 1px; the header toggle at line 379 shares the same treatment.

Requested fix: Keep the shared outline unobscured inside the actual compact-cell boundary, using the smallest offset/paint-owner correction rather than widening unrelated controls. Cover both toggles across densities with browser focus/pixel evidence. The three atom-class tests may remain composition evidence but must not be treated as clipping proof.

Validation boundary: these findings are grounded in the exact implementation and relevant tests. Isolated source/geometry probes are not fresh mounted React, browser, clipboard, screen-reader or native-device certification. Retain the applicable focused tests and head-bound evidence when updating the PR.

@cixzhang

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 61cc6f4

@astracat-bot astracat-bot Bot 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.

Thanks: the shared focus ring now reaches the scroll wrapper and both tree toggles, the Card-edge and compact-density clipping from the last round is fixed, and the new Chromium spec covers the fit. Two things need to change before this merges:

  • The last commit adds 119 files under packages/core/src/i18n/generated-english/ that come from main's newer i18n generator (which ignores that directory), not this branch's, plus formatting-only rewrites of 17 Table files the fix does not touch, so please drop both.
  • The changeset says a Card "shows all of" the wrapper's ring, but the Card's rounded corners (11px inner radius) cut off the square ring's corners, and the Chromium spec misses this because it models each clip as a rectangle, so either round the ring to the clip and teach the spec about border-radius, or limit the changeset to the edges.

The description still gives the previous inset and test count, and three new comments could be shorter (see the inline suggestions). An engineering owner's change request from the previous round is still open and needs their re-review.

[Automated review]

Comment thread .changeset/table-focus-ring.md Resolved
Comment on lines +137 to +139
// The wrapper bleeds to its container's edges, under a Card's border, and
// the Card clips there, so its keyboard ring sits inside its own box, clear
// of that border too.

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.

Non-blocking: one 37-word sentence with three topics. Suggest: "The wrapper bleeds under a Card's border, and the Card clips there. The ring sits inside the wrapper, clear of the border."

Comment on lines +182 to +183
// A tab stop once the table scrolls inline: the shared ring, which a
// theme restyles through the focus-outline tokens.

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.

Non-blocking: the second half restates focusOutlineStyles.focusVisible. Suggest: "The wrapper is a tab stop while the table scrolls inline."

Comment on lines +247 to +248
// A compact row is shorter than the ring around the 24px toggle, and the
// cell clips its overflow, so there the ring sits inside the toggle.

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.

Non-blocking: one 28-word sentence. Suggest: "A compact cell clips the ring around the 24px toggle. At compact density the ring sits inside the toggle."

… tree toggles ring inside; a Chromium spec checks each ring's fit
@cixzhang
cixzhang force-pushed the lane4/focus-ring-table branch from 61cc6f4 to 1ce8da1 Compare November 5, 2026 18:09

@astracat-bot astracat-bot Bot 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.

Changes requested. The three Table tab stops now draw the shared, token-driven focus ring, and the Card-edge and compact-density clipping from earlier rounds is fixed, but two things need to change before this merges:

  • The last commit adds 119 files under packages/core/src/i18n/generated-english/ that come from main's newer i18n generator (which ignores that directory), plus formatting-only rewrites of 17 Table files the fix does not touch, so please drop both.
  • The changeset says a Card "shows all of" the wrapper's ring, but the Card's rounded corners (11px inner radius) cut off the square ring's corners and the Chromium spec misses it because it models each clip as a rectangle, so either round the ring to the clip and teach the spec about border-radius, or limit the changeset to the edges.

The description still gives the earlier inset (−2px) and test count, and three new comments could be shorter (see the inline suggestions). An engineering owner's change request from an earlier revision is still open and needs their re-review.

[Automated review]

Comment thread .changeset/table-focus-ring.md Resolved
Comment on lines +137 to +139
// The wrapper bleeds to its container's edges, under a Card's border, and
// the Card clips there, so its keyboard ring sits inside its own box, clear
// of that border too.

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.

Non-blocking: one 30-word sentence with three topics. Suggest: "The wrapper bleeds under a Card's border, and the Card clips there. The ring sits inside the wrapper, clear of the border."

Comment on lines +182 to +183
// A tab stop once the table scrolls inline: the shared ring, which a
// theme restyles through the focus-outline tokens.

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.

Non-blocking: the second half restates focusOutlineStyles.focusVisible. Suggest: "The wrapper is a tab stop while the table scrolls inline."

Comment on lines +247 to +248
// A compact row is shorter than the ring around the 24px toggle, and the
// cell clips its overflow, so there the ring sits inside the toggle.

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.

Non-blocking: one 26-word sentence. Suggest: "A compact cell clips the ring around the 24px toggle. At compact density the ring sits inside the toggle."

@cixzhang

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec cd72770

@astracat-bot astracat-bot Bot 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.

Changes requested. The three Table tab stops now draw the shared, token-driven focus ring, its edges clear a bordered Card, and the changeset describes the Card's corners honestly; what blocks is that the branch is behind main:

  • Miss: useTableTreeData.tsx conflicts with main in its import block and in both toggles, because main moved them to useComponentTranslator and added getRowLabel naming, so please rebase, keep main's side, and re-add the TableContext import and the isCompact read with the ring props (with that resolution the Table and tree suites pass, 242 tests).
  • Miss: TableFocusRing.a11y.chromium.spec.ts imports @astryxdesign/a11y-spec/playwright, which this branch's internal/a11y-spec does not export, so core's typecheck fails at this head with five errors in that file (the same rebase fixes it).

An engineering owner's change request from an earlier revision is still open; this head addresses both of its points, but only that owner can clear it. CI has not run yet because the pull request is a draft.

[Automated review]

@cixzhang
cixzhang marked this pull request as ready for review November 5, 2026 22:15
# Conflicts:
#	packages/core/src/Table/plugins/tree/useTableTreeData.tsx
@cixzhang

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec a915c4a

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 294eda1

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
TableBody 3.5 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · ✗
TableFooter 3.5 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · ✗
TableHeader 3.5 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · ✗
8 more components
Component Size LoC Visual · A11y · RTL
TableRow 6.9 kB (0) · 3.9 kB CSS (0) — ✓ · ✓ · ✗
Markdown 177.7 kB (+32 B) · 20.0 kB CSS (+24 B) — — · — · —
Table 115.3 kB (+23 B) · 17.7 kB CSS (+24 B) — ✓ · ✓ · —
lab/CommentThread 317.4 kB (+30 B) · 2.4 kB CSS (0) — — · — · —
lab/Comments 322.4 kB (+18 B) · 2.5 kB CSS (0) — — · — · —
TableCell 107.1 kB (0) · 17.4 kB CSS (0) — ✓ · ✓ · ✓
TableHeaderCell 106.6 kB (0) · 17.2 kB CSS (0) — ✓ · ✓ · ✓
TableSelectionToolbar 68.0 kB (0) · 13.0 kB CSS (0) — ✓ · ✓ · ✓

Package size: @astryxdesign/core 6.90 MB packed (+743 B); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 21 rows, core 25 rows; run pnpm api:report.

Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot 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.

No blocking findings at this head: the scroll wrapper and both tree toggles draw the shared, token-driven focus ring, the wrapper's ring fits inside a bordered Card on every edge, and at compact density the toggles' ring sits inside the button.

What is left is not a code change:

  • An engineering owner's change request from an earlier revision is still open; this head addresses both of its points (the Card clip and the compact-density clip), but only that owner can clear it by re-reviewing or dismissing it.

CI's build and test jobs are deferred on this head and run before merge, so they still have to pass. Three new source comments could be shortened to their reason, as the existing inline suggestions show; that is optional.

[Automated review]

@cixzhang
cixzhang dismissed humbertovirtudes’s stale review November 6, 2026 01:23

Dismissed by Cindy's agent with her authorization: head a915c4a addresses both points: (1) the scroll wrapper's ring is inset by the outline width plus the theme border width (Table.tsx:146-150), so its outer edge sits inside a bordered Card's clip; a real-Chrome check against this head's Storybook build, measuring the ring against every clipping ancestor, finds nothing cut at 480 and 1280 px left-to-right, 390 and 1280 px right-to-left, and theme border widths of 0, 1 and 3 px, and the changeset now claims the edges only (a Card's rounded corners still trim the ring's square corners); (2) at compact density both tree toggles inset their ring (useTableTreeData.tsx:270, 364-379, 421-428), and the same check finds nothing cut for the row expander and the expand-all toggle at compact and default density, in both directions.

@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 76dcfdf

@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 7, 2026

@astracat-bot astracat-bot Bot 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.

Approved pending CI: the build, test and docsite jobs have not run on this head yet (they are deferred until before merge), so they still have to pass.

No blocking findings. The scroll wrapper and both tree toggles draw the shared, token-driven focus ring; the wrapper's ring fits inside a bordered Card on every edge in both directions; and at compact density the toggles' ring sits inside the button. Both points from the earlier change request, the Card clip and the compact-density clip, are fixed at this head.

Optional: three new source comments could be shortened to their reason, as the existing inline suggestions show.

[Automated review]

@cixzhang cixzhang closed this Nov 7, 2026
@cixzhang cixzhang reopened this Nov 7, 2026
…-conditional-attr

Every TableTree story already carries this baselined exception (the tree rows' aria-expanded inside a table); the CompactDensity story added here shows the same rows.
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec fe868a8

@astracat-bot astracat-bot Bot 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.

Changes requested. The focus-ring fix itself holds up: the scroll wrapper and both tree toggles draw the shared, token-driven ring, inside a bordered Card and at compact density. One thing in the newest commit needs fixing:

  • The baseline entry at .github/a11y-baseline.json:337 keys the story as core/TableTree::…, but the accessibility gate builds the key from the owner core/tabletree and matches it exactly, so the CompactDensity story's aria-conditional-attr is still reported as new (the touched-components check stays red, and the release check's full audit would fail after merge); write it as core/tabletree::core-tabletree--compact-density::aria-conditional-attr, or regenerate it with pnpm a11y:baseline -- --components tabletree.

[Automated review]

Comment thread .github/a11y-baseline.json Resolved
…ercase owner

The gate builds keys from the story owner core/tabletree and matches exactly.
@cixzhang

cixzhang commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 294eda1

@astracat-bot astracat-bot Bot 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.

Approved pending CI: the heavy suites (test, build, docsite-test) are deferred on this head and run before merge; lint, typecheck and the smoke test pass.

The baseline entry for the CompactDensity story now uses the owner the accessibility gate computes, core/tabletree, and the gate passes for the TableTree stories with no new violations. The focus-ring fix itself is unchanged and holds up: the scroll wrapper and both tree toggles draw the shared, token-driven ring, with whole edges inside a bordered Card and inside the toggle at compact density.

The three earlier comment-wording suggestions stay open as inline threads; they are non-blocking.

[Automated review]

This branch was successfully deployed

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

Labels

ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants