Skip to content

fix(CodeBlock, Carousel): the code viewport and the scroller draw the shared focus ring - #8875

Merged
cixzhang merged 12 commits into
mainfrom
lane4/focus-ring-codeblock-carousel
Nov 6, 2026
Merged

cixzhang merged 12 commits into
mainfrom
lane4/focus-ring-codeblock-carousel

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Part of #8852 (CodeBlock and Carousel; Table is #8873, ChatMessageList, Tooltip and HoverCard follow)

User impact

A keyboard user who tabs into an overflowing CodeBlock or into a Carousel gets the browser's default focus ring instead of the theme's. It has its own colour, width and style and looks different in each browser. On an overflowing carousel the scroller's edge-fade mask fades the ring on its faded side. After this change both draw the same theme-driven ring as every other Astryx control, whole, inside the component.

Problem and solution fit

  • Why the browser's ring? The code viewport (a tab stop once the code overflows) and the carousel scroller (always a tab stop) carry no ring style, so they fall back to the user-agent default. WCAG 2.4.7 needs a visible indicator, and the --focus-outline-* tokens are how Astryx draws one.
  • Why is it cut off? Both sit flush inside a clipping root: CodeBlock's root clips its corners (overflow: hidden), and the carousel root clips with a 1px margin.
  • Why does it matter? A theme that restyles the ring reaches every other control but not these two.

Both compose the shared ring, inset by its own width so it stays inside the clip. That's the same inset the Table scroll wrapper and ChatToolCalls use.

Expected behavior and authority

Smallest restoration

  • CodeBlock.tsx: the viewport composes focusOutlineProps.focusVisible plus an inset offset. The collapse toggle already had the shared ring.
  • Carousel.tsx: the scroller is the focus owner (focusOwnerProps) and paints no ring of its own (focusOutlineStyles.suppressed). The root takes focusWithinOwnerOverlay from privateAttributes/focusOwner.stylex.ts: the shared ring drawn as a ::after overlay above the root's content and inset by the ring's width, keyed on the owner attribute (architecture:interaction-modality INV3). The overlay is needed because the scroller's edge-fade mask would erase a ring the scroller painted, and it makes the scroller a stacking context that covers a ring the root painted. INV1 names the overlay for wrappers whose content would cover their ring.
  • __tests__/insetFocusRing.ts: a small test helper asserting the shared ring, plain or inset, by its compiled atoms.
  • 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. Computed outline, and the painted ring against the clipping root (its overflow-clip-margin included):

Tab stop (story) Width main This PR
CodeBlock viewport (Diff long lines) 1280, 390 auto 1px UA ring solid 2px theme colour, offset -2px; whole inside the root
Carousel scroller (Default) 1280, 390 auto 1px UA ring; faded on the inline-end side by the edge-fade mask solid 2px theme colour, inset -2px on the root's overlay; every edge painted
  • Regression tests: CodeBlock.focusRing.test.tsx and Carousel.focusRing.test.tsx, both failing on main. jsdom doesn't match :focus-visible, so they pin the composition; the browser check above covers the geometry.
  • Representative unchanged path: the CodeBlock and Carousel suites, 198 tests.

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 for CodeBlock and Carousel: 198 pass, with the new tests failing first.
  • tsc --noEmit for core, eslint, prettier.
  • The real-Chrome probe above, desktop and 390 px.

Chromium evidence

CarouselFocusRing.a11y.chromium.spec.ts checks painted pixels: the midpoint of each edge of the Carousel root shows the ring colour, at rest and mid-scroll, on Default and on full-height Card Content. It also checks the CodeBlock viewport ring. Against this head's exact Vercel Storybook (2858800), all 3 pass. Against main all 3 fail, because the ring is the browser's auto outline.

Writing rubric results

The record change is one sentence in architecture:interaction-modality INV1.

  • R1 narration: none; the sentence states the system in the present tense.
  • R2 research in the record: none.
  • R3 evidence naming a change: none.
  • R4 rejected alternatives: none added.
  • R5 pull request or issue references: none in the record.
  • R6 open questions: none.

@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 6, 2026 12:11am 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 6, 2026, 6:02 AM 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.

Changes requested: moving both elements onto the shared focus ring and its tokens is the right fix, and the CodeBlock half works as described, but on an overflowing Carousel the scroller's own edge-fade mask still hides the ring on its faded side. Please paint the ring where the mask does not reach (or move the fade off the focusable scroller), and back the fix with a real-browser check.

  • With the default edge fade, the ring's inline-end edge at rest, and both side edges mid-scroll, paint at about a quarter of the ring's strength on the Default story, so the changeset's "no longer cuts them off" does not hold for Carousel yet.
  • The new tests compare StyleX class names in jsdom, which cannot match :focus-visible or see paint; a case in the existing CodeBlock and Carousel Chromium specs that tabs in and checks the rendered ring would cover this.

[Automated review]

Comment thread packages/core/src/Carousel/Carousel.tsx Outdated
// A tab stop: the shared ring, which a theme restyles through the
// focus-outline tokens.
focusOutlineStyles.focusVisible,
styles.scrollerFocusRingInset,

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.

This ring sits on the element that also carries the edge-fade mask-image (applied a few lines below through fadeStyle). A mask covers everything its element paints, outline included, and the inset puts the side edges inside the mask's 0–30% ramp: on the Default story at rest the inline-end edge paints at about a quarter of the ring's strength, and mid-scroll both side edges do. Painting the ring where the mask does not reach (for example a root-level overlay shown while the scroller matches :focus-visible), or moving the fade off the focusable element, would keep it whole.

Comment on lines +21 to +28
const inset = stylex.create({
ring: {
outlineOffset: {
default: null,
':focus-visible': `calc(-1 * ${focusVars['--focus-outline-width']})`,
},
},
});

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.

This re-creates the components' own inset declaration and then checks that the element carries the same atoms, in jsdom, which neither matches :focus-visible nor paints, so the tests pass while the Carousel ring is masked on its faded side. A case in the existing Chromium specs (CodeBlockOverflowStop.a11y.chromium.spec.ts, Carousel.a11y.chromium.spec.ts) that tabs to the element and checks the computed outline and that each edge paints would guard the actual outcome.

@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
…mask no longer erases it; a Chromium spec checks both rings paint whole
@cixzhang

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec d596876

@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 CodeBlock half works as described, and moving the Carousel ring to the root fixes the edge fade on the Default story, but on carousels whose slides fill the height the slides now cover most of the ring.

  • On an overflowing Carousel with full-height slides (Card Content, Color Swatches), the scroller's edge-fade mask makes it a stacking context that paints over the root's inset ring, so only short stubs of the top, bottom and inline-start edges stay visible; paint the ring above the scroller (for example a root overlay built from the shared focus-outline styles) or move the mask off the ringed box.
  • The new Chromium spec checks computed outline styles and ancestor masks rather than paint, so it passes on Card Content with the ring hidden; add a full-height-slide case that checks the painted ring edges.
  • Newly live check: the description says the base clip cuts off the carousel ring's bottom edge, but on the base Default story that edge paints in full and the base loss is the faded inline-end edge, and its "Smallest restoration" bullet still describes the scroller painting the ring; please correct both.
  • The Carousel.doc.mjs rewrap changes no content and conflicts with main; please drop it from this pull request.

With those fixed, the changeset's "show whole" wording will match what ships.

[Automated review]

Comment thread packages/core/src/Carousel/Carousel.tsx Outdated
stylex.props(
styles.root,
// The scroller is the root's first child and its tab stop.
focusOutlineStyles.focusWithinFirstChild,

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.

While the content overflows, the scroller's edge-fade mask-image makes it a stacking context that Chromium paints after this root's outline, so slides that reach the scroller's top or bottom cover the inset ring: on Card Content only 148 of 1,000 top-edge device pixels stay visible, against all 1,000 with the mask removed. Painting the ring above the scroller (a root overlay stacked over it, from the shared focus-outline styles) or moving the mask off this box would keep it whole.

}

/** Find which element paints the focused element's ring, and measure it. */
async function measureRing(page: Page): Promise<RingPaint> {

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.

This measures computed outline style and width plus ancestor masks and clips, not paint, so on Card Content it returns a whole ring (masked: [], clipped: []) while the slides hide most of it. A full-height-slide case that samples the ring's edge pixels in a screenshot would catch that.

displayName: 'Carousel',
category: 'Container',
keywords: ['carousel', 'slider', 'scroll', 'gallery', 'filmstrip', 'swiper', 'horizontal', 'overflow', 'snap'],
keywords: [

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.

This file only changes formatting (all three exports are deep-equal to the base), and merging main conflicts here; dropping it keeps the fix focused.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 2858800

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Carousel · Storybook 58.1 kB (+241 B) · 9.7 kB CSS (+202 B) 505 (+12) ✓ · ✓ · ✓
PowerSearch 263.3 kB (+141 B) · 22.9 kB CSS (+128 B) — — · — · —
Pagination 98.7 kB (+139 B) · 16.9 kB CSS (+103 B) — — · — · —
6 more components
Component Size LoC Visual · A11y · RTL
Selector 88.7 kB (+139 B) · 16.5 kB CSS (+96 B) — — · — · —
CodeBlock · Storybook 65.5 kB (+42 B) · 10.1 kB CSS (+18 B) 2,225 (+10) ✓ · ✓ · ✓
Markdown 160.1 kB (+45 B) · 19.3 kB CSS (0) — — · — · —
lab/Comments 280.6 kB (new) · 2.5 kB CSS (new) — — · — · —
lab/CommentThread 274.8 kB (new) · 2.4 kB CSS (new) — — · — · —
richtext/RichTextEditorToolbar 239.3 kB (new) · 454 B CSS (new) — — · — · —

Package size: measured; main has no measurement of the merge base to compare yet.

API changes: cli +14 · ~5 · −0 (against the merge base's committed report)

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

19 API changes (advisory)
Package Where Signature Usage
+ cli ./api · Types · type SearchResultEntry deprecated?: ComponentDeprecation | undefined import type {SearchResultEntry} from '@astryxdesign/cli/api'; const x: SearchResultEntry = {deprecated: …}
+ cli ./authoring · Types · interface ComponentDeprecation interface ComponentDeprecation import type {ComponentDeprecation} from '@astryxdesign/cli/authoring'
+ cli ./authoring · Types · interface ComponentIconSlotDoc interface ComponentIconSlotDoc import type {ComponentIconSlotDoc} from '@astryxdesign/cli/authoring'
+ cli ./authoring · Types · interface ComponentIconSlotStateDoc interface ComponentIconSlotStateDoc import type {ComponentIconSlotStateDoc} from '@astryxdesign/cli/authoring'
+ cli ./authoring · Types · interface MultiComponentDoc deprecated?: ComponentDeprecation import type {MultiComponentDoc} from '@astryxdesign/cli/authoring'; const x: MultiComponentDoc = {deprecated: …}
+ cli ./authoring · Types · interface SingleComponentDoc deprecated?: ComponentDeprecation import type {SingleComponentDoc} from '@astryxdesign/cli/authoring'; const x: SingleComponentDoc = {deprecated: …}
+ cli ./doc · Types · interface ComponentBaseDoc deprecated?: ComponentDeprecation import type {ComponentBaseDoc} from '@astryxdesign/cli/doc'; const x: ComponentBaseDoc = {deprecated: …}
+ cli ./doc · Types · interface SubComponentDoc deprecated?: ComponentDeprecation import type {SubComponentDoc} from '@astryxdesign/cli/doc'; const x: SubComponentDoc = {deprecated: …}
+ cli ./doc · Also exported from an earlier entry point · ComponentDeprecation ComponentDeprecation (./authoring) import {ComponentDeprecation} from '@astryxdesign/cli/doc'
+ cli ./doc · Also exported from an earlier entry point · ComponentIconSlotDoc ComponentIconSlotDoc (./authoring) import {ComponentIconSlotDoc} from '@astryxdesign/cli/doc'
+ cli ./doc · Also exported from an earlier entry point · ComponentIconSlotStateDoc ComponentIconSlotStateDoc (./authoring) import {ComponentIconSlotStateDoc} from '@astryxdesign/cli/doc'
+ cli ./template · Also exported from an earlier entry point · ComponentDeprecation ComponentDeprecation (./authoring) import {ComponentDeprecation} from '@astryxdesign/cli/template'
+ cli ./template · Also exported from an earlier entry point · ComponentIconSlotDoc ComponentIconSlotDoc (./authoring) import {ComponentIconSlotDoc} from '@astryxdesign/cli/template'
+ cli ./template · Also exported from an earlier entry point · ComponentIconSlotStateDoc ComponentIconSlotStateDoc (./authoring) import {ComponentIconSlotStateDoc} from '@astryxdesign/cli/template'
~ cli ./api · Functions · function search function search: (query: string, options?: { cwd?: string | undefined; type?: "template" | "component" | "hook" | "theme" | "doc" | undefined; limit?: number | undefined }) => Promise<SearchResponse> → function search: (query: string, options?: { cwd?: string | undefined; type?: "template" | "component" | "doc" | "theme" | "hook" | undefined; limit?: number | undefined }) => Promise<SearchResponse> import {search} from '@astryxdesign/cli/api'; search(…)
~ cli ./authoring · Types · interface MultiComponentDoc theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[] } → theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[]; componentIcons?: ComponentIconSlotDoc[] } import type {MultiComponentDoc} from '@astryxdesign/cli/authoring'; const x: MultiComponentDoc = {theming: …}
~ cli ./authoring · Types · interface SingleComponentDoc theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[] } → theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[]; componentIcons?: ComponentIconSlotDoc[] } import type {SingleComponentDoc} from '@astryxdesign/cli/authoring'; const x: SingleComponentDoc = {theming: …}
~ cli ./doc · Types · interface ComponentBaseDoc theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[] } → theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[]; componentIcons?: ComponentIconSlotDoc[] } import type {ComponentBaseDoc} from '@astryxdesign/cli/doc'; const x: ComponentBaseDoc = {theming: …}
~ cli ./doc · Types · interface SubComponentDoc theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[] } → theming?: { container?: boolean; targets: ComponentThemingTarget[]; vars?: ComponentThemingVar[]; derived?: ComponentThemingDerivedVar[]; componentIcons?: ComponentIconSlotDoc[] } import type {SubComponentDoc} from '@astryxdesign/cli/doc'; const x: SubComponentDoc = {theming: …}

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.

Changes requested: thanks for dropping the doc rewrap. The CodeBlock half works as described, but on carousels whose slides fill the height, the slides still cover most of the new ring.

  • On an overflowing Carousel with full-height slides (Card Content, Custom Content (Swatches)), the scroller's edge-fade mask makes it a stacking context that paints over the root's inset ring, so only short stubs of the top, bottom and inline-start edges stay visible; paint the ring above the scroller (for example a root overlay built from the shared focus-outline styles) or move the mask off the ringed box.
  • The new Chromium spec checks computed outline styles and ancestor masks rather than paint, so it passes on Card Content with the ring hidden; add a full-height-slide case that checks the painted ring edges.
  • Newly live check: the description says the base clip cuts off the carousel ring's bottom edge, but on the base Default story that edge paints in full (the base loss is the faded inline-end edge), and its "Smallest restoration" bullet still describes the scroller painting the ring; please correct both.

With those fixed, the changeset's "show whole" wording will match what ships.

[Automated review]

…roller; the Chromium spec checks painted edges, full-height slides included
@cixzhang

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 38f9caf

@cixzhang
cixzhang marked this pull request as ready for review November 5, 2026 22:15

@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 ring itself now looks right: in Chromium the CodeBlock viewport and the Carousel scroller both draw the theme's ring, whole on every edge, at rest and mid-scroll, including full-height card slides. Four things block merging:

  • Carousel.tsx adds the --_carousel-ring-style custom property, which fails the existing derivedVarRegistry.test.ts check "Carousel: all source vars are in doc file" (red in test-ui).
  • CarouselFocusRing.a11y.chromium.spec.ts imports @astryxdesign/a11y-spec/playwright, a subpath this branch's harness does not export, so core's typecheck fails with 7 errors and the accessibility-contracts job cannot run the spec; merge main into the branch or import from the subpaths this base exports.
  • The Carousel overlay re-creates the shared ring locally (the :has(> :first-child:focus-visible) condition plus the width, style and colour), so please add the overlay as a variant in utils/focusOutline.stylex.ts and have Carousel's root make one call to it, which also removes the custom property above.
  • The 119 files under packages/core/src/i18n/generated-english/ are generator output from main, which main ignores and nothing on this branch imports; please remove them from the branch.

A non-blocking wording suggestion for the overlay's code comment is inline.

[Automated review]

Comment thread packages/core/src/Carousel/Carousel.tsx Outdated
Comment on lines +169 to +185
focusRingOverlay: {
'--_carousel-ring-style': {
default: 'none',
':has(> :first-child:focus-visible)': focusVars['--focus-outline-style'],
},
'::after': {
content: '""',
position: 'absolute',
inset: 0,
pointerEvents: 'none',
borderRadius: 'inherit',
outlineStyle: 'var(--_carousel-ring-style)',
outlineWidth: focusVars['--focus-outline-width'],
outlineColor: focusVars['--focus-outline-color'],
outlineOffset: `calc(-1 * ${focusVars['--focus-outline-width']})`,
},
},

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.

This re-creates the shared ring in the component: the :has(> :first-child:focus-visible) condition is the one focusOutlineStyles.focusWithinFirstChild already owns, and the width, style and colour longhands are restated on the ::after. Two consequences: a later fix to the shared ring will not reach Carousel, and the new --_carousel-ring-style fails derivedVarRegistry.test.ts ("Carousel: all source vars are in doc file"). Adding the overlay as a variant in utils/focusOutline.stylex.ts (ring on ::after, inset by its width, same condition) and composing it here as one call would fix both.

Comment thread packages/core/src/Carousel/Carousel.tsx Outdated
Comment on lines +165 to +168
// The scroller's keyboard ring is an overlay on the root, painted after the
// scroller: the scroller's edge-fade mask would erase a ring the scroller
// painted itself, and makes the scroller a stacking context that covers a
// ring painted by the root. The ring sits inside the root's clipped box.

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 first sentence is 43 words and carries several topics. A shorter version that keeps the reason: "The scroller's edge-fade mask erases a ring the scroller paints. The mask also makes the scroller a stacking context that covers a ring on the root. So the root paints the ring on an overlay above the scroller."

* :focus-visible or paint
*/

import {expect, test, type Page} from '@astryxdesign/a11y-spec/playwright';

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.

On this branch internal/a11y-spec/package.json exports only ., ./chromium and ./storybook; ./playwright exists only on main. Core's typecheck fails here (plus six implicit-any errors that follow from it), and the accessibility-contracts job stops at "Package subpath './playwright' is not defined by exports", so this spec never runs at this head. Merging main into the branch, or importing from the exported subpaths, would let it run.

// Copyright (c) Meta Platforms, Inc. and affiliates.

/**
* @generated by scripts/generate-i18n-runtime.mjs from packages/core/locales/en.json,

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.

This and the other 118 files under generated-english/ are output of main's i18n generator (this branch's generator does not write this directory), and main's .gitignore excludes the directory. Nothing on this branch imports them and 61 of their strings differ from this branch's en.json; once merged they would be tracked files that every pnpm install rewrites. Please remove the directory from the branch.

@cixzhang

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec f6cacd4

@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: both rings now look right, since in Chromium the CodeBlock viewport and the Carousel scroller paint the theme's 2px ring inside their components, and the Carousel ring is whole on every edge at rest, mid-scroll and in right-to-left. The earlier unit-test, typecheck and stray-file problems are fixed.

Blocking:

  • The Carousel root paints its scroller's ring with a new :has(> :first-child:focus-visible) overlay in internal/focusOutline.stylex.ts instead of the shared focus-owner style and attribute that architecture:interaction-modality INV3 on main now requires for a wrapper that rings one primary control among other tab stops (Carousel.tsx:601), so after merging main the overlay belongs in privateAttributes/focusOwner.stylex.ts, keyed on the owner attribute with focusOwnerProps on the scroller (or an engineering owner amends INV3 to name the overlay), with the INV1 sentence updated to match and the new head re-approved.

CI did not run on this head because the run found no room under the CI ceiling, so it needs a re-run with the next push. The inline comments also carry three small non-blocking cleanups.

[Automated review]

Comment thread packages/core/src/Carousel/Carousel.tsx Outdated
styles.root,
// The scroller is the root's first child and its tab stop. Its
// edge-fade mask would cover a ring the root draws itself.
focusOverlayStyles.firstChild,

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.

This root rings for one primary control (the scroller) among other tab stops, which architecture:interaction-modality INV3 on main now routes through privateAttributes/focusOwner.stylex.ts: the primary carries focusOwnerProps and the wrapper ring keys on that attribute, so nested owners and sibling controls ring themselves and a fix to the wrapper ring reaches every wrapper. focusOverlayStyles.firstChild keys on :first-child instead, a second copy of focusWithinFirstChild's condition. After merging main, an overlay export in the focus-owner module (only that file may write the attribute's selector) plus {...focusOwnerProps} on the scroller would meet INV3 and keep the overlay; the INV1 sentence would then name that module.

radiusVars,
durationVars,
easeVars,
focusVars,

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: focusVars is no longer used in this file now that the overlay lives elsewhere (@typescript-eslint/no-unused-vars warns).

@@ -0,0 +1,243 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
// @pr-a11y scope ^(packages/core/src/(Carousel|CodeBlock)/|packages/core/src/utils/focusOutline|apps/storybook/stories/(Carousel|CodeBlock)\.stories)

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: this scope still names utils/focusOutline but not the module that now draws the Carousel ring, so a labelled accessibility run skips this spec when only the overlay changes. Adding that module's path keeps the painted-ring check attached to the code it guards.

Comment on lines +1254 to +1255
// A tab stop while the code overflows: 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 what focusOutlineProps.focusVisible is. A shorter comment that keeps the reason: "The viewport is a tab stop only while the code overflows."

… focus-owner overlay ring (interaction-modality INV3); the internal entry is gone
@cixzhang

cixzhang commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 2858800

@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: CI has not run on this head yet (the run was cancelled for lack of capacity), so it needs a re-run before merge.

Both rings now come from the theme's focus tokens: the CodeBlock viewport's ring sits inside the clipped root, and the Carousel ring is drawn by the shared focus-owner overlay keyed on the scroller, which resolves the earlier finding. In Chromium the Carousel ring paints on all four edges (default, full-height cards at rest and mid-scroll, right-to-left), a mouse hand-off still shows no ring, and the new Chromium spec passes against this head.

Non-blocking:

  • Carousel.tsx:44 still imports focusVars, which is now unused.
  • The spec's @pr-a11y scope (CarouselFocusRing.a11y.chromium.spec.ts:2) does not name privateAttributes/focusOwner, so a change to the overlay alone would not run it.
  • Two new comments could be shorter (focusOwner.stylex.ts:48-52, CodeBlock.tsx:1254-1255).
  • Miss: the CodeBlock ring's two bottom corners are clipped by the root's rounded corners; the edges paint whole.

[Automated review]

Comment on lines +48 to +52
// The same ring, drawn as an overlay pseudo-element above the wrapper's
// content and inset by the ring's width, for a marked control whose own
// painting would cover a ring on the wrapper: a scroller with an edge-fade
// mask is its own stacking context. The wrapper must be positioned and must
// not use ::after.

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 first sentence is 43 words and carries several topics. A shorter version that keeps the reason: "The same ring on an overlay above the wrapper's content, inset by its width. Use it when the marked control covers a ring on the wrapper: an edge-fade mask makes a scroller its own stacking context. The wrapper must be positioned and must not use ::after."

Comment on lines +146 to +153
// The root clips (overflow: hidden, for its corners), so the viewport's
// keyboard ring sits inside its own box instead of around it.
viewportFocusRingInset: {
outlineOffset: {
default: null,
':focus-visible': `calc(-1 * ${focusVars['--focus-outline-width']})`,
},
},

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: in Chromium this ring's two bottom corners are clipped on a diagonal by the root's rounded corners (--radius-element), about 4 to 5 px of each leg on Diff Long Lines; the edges paint whole. Rounding the viewport's bottom corners to match the root would let the outline follow the curve.

@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, for one description fix: the code side is ready. Both rings now come from the theme's focus tokens, the Carousel ring paints on every edge in Chromium, and the new tests and Chromium spec pass on this head.

  • Miss: this pull request changes architecture:interaction-modality INV1, but the ## Writing rubric results section of the description is empty; add one line per rubric item (R1 to R6 in docs/contributing/spec-writing.md), as docs/architecture/knowledge-contracts.md requires for every record change.

Editing the description adds no commit, so the spec approval for this head still holds. The earlier non-blocking notes still stand (the unused focusVars import, the spec's @pr-a11y scope, two long comments, the CodeBlock ring's bottom corners), and the header of focusOwner.stylex.ts should also name the new export.

[Automated review]

Comment on lines +136 to +140
focus indicator; after keyboard input it does. A wrapper whose content would
cover a ring it draws, such as a masked scroller that is its own stacking
context, draws the shared ring as the focus-owner overlay
(`focusWithinOwnerOverlay` in `privateAttributes/focusOwner.stylex.ts`), keyed
on the owner attribute as INV3 says.

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.

This record change needs its writing-rubric results in the pull request description: one line per item, R1 to R6 of docs/contributing/spec-writing.md, under ## Writing rubric results, as docs/architecture/knowledge-contracts.md asks of every record change. The heading is there but empty. Editing the description adds no commit, so the spec approval for this head still holds.

export const focusWithinOwner = styles.focusWithinOwner;

/** The wrapper's focus ring, drawn above the wrapper's content. */
export const focusWithinOwnerOverlay = styles.focusWithinOwnerOverlay;

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 file header's @output (lines 6-7) still lists only focusWithinOwner and focusOwnerProps. Add this export there so the header stays accurate.

@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. The description now reports the writing-rubric results for the INV1 change, which was the one remaining item. Both rings come from the theme's focus tokens: the CodeBlock viewport's ring sits inside the clipped root, and the Carousel ring paints on every edge at rest and mid-scroll, while pointer focus stays ringless.

The earlier non-blocking notes still stand and can go in a follow-up: the unused focusVars import in Carousel.tsx, the Chromium spec's @pr-a11y scope (add privateAttributes/focusOwner), the focusOwner.stylex.ts header and two long comments, the CodeBlock ring's thinned bottom corners, and the unused expectSharedFocusRing test helper.

[Automated review]

);

/** The element draws the shared ring at the token offset. */
export function expectSharedFocusRing(el: Element): void {

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: nothing imports expectSharedFocusRing (SideNav.test.tsx keeps its own local copy of the same check). Delete it here, or have SideNav import it, so the shared-ring assertion lives in one place.

@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 6, 2026
@cixzhang cixzhang closed this Nov 6, 2026
@cixzhang cixzhang reopened this Nov 6, 2026
@cixzhang
cixzhang merged commit f81f09d into main Nov 6, 2026
163 of 169 checks passed
@github-actions
github-actions Bot deleted the lane4/focus-ring-codeblock-carousel branch November 7, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — 28588005 Deployed Nov 6, 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.

1 participant