Skip to content

fix(Selector): a ghost or secondary trigger's clear and status buttons ring themselves, not the trigger too - #8874

Merged
cixzhang merged 27 commits into
mainfrom
fix/focus-ring-one-owner-thumbnail-selector
Nov 5, 2026
Merged

cixzhang merged 27 commits into
mainfrom
fix/focus-ring-one-owner-thumbnail-selector

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Part of #8850, for Selector only. It no longer stacks on #8869 or #8872: it carries the focus-owner owner module that Selector needs, so it lands on its own.

User impact

A keyboard user who tabs to the clear or status button of a ghost or secondary Selector sees two rings: the button's, and a second around the whole trigger. Now each tab stop shows one ring.

Clear focused, ghost Selector Before After
1280
390

Problem and solution fit

  • Cause: the ghost and secondary trigger box rings with focusWithin, which matches any focused descendant, including the clear and status buttons.
  • Fix: the trigger box spreads focusWithinOwner and the trigger button spreads focusOwnerProps, both from the new owner module privateAttributes/focusOwner.stylex.ts. The box rings only while its own trigger button has keyboard focus. The input variant, which draws focus as a border, is unchanged.
  • Owner module: the only file that writes data-astryx-focus-owner or its selector, as architecture:interaction-modality INV3 names it. The focus-outline-shared lint rule allows the ring there.

Changes

  • Selector.tsx: trigger box and trigger button, as above.
  • privateAttributes/focusOwner.stylex.ts (new), focusOwner.source-build.test.mjs (new).
  • internal/eslint-plugin-astryx/focus-outline-shared.js and its test: the owner module may write the ring.
  • docs/architecture/interaction-modality.md INV3: the implementation gap no longer says the module is missing, and no longer lists Selector.
  • FocusRingOwner.a11y.chromium.spec.ts (new) with focusRings.ts: ghost and secondary Clearable Selector, at 1280 and 390 px.
  • .changeset/focus-ring-one-owner-selector.md.

Split out: MultiSelector's change (held for a separate decision), and Thumbnail, Item, Token and the cards, which #8869 and #8872 carry.

Writing rubric results

  • INV3's gap sentence, present tense, no history: pass.
  • One fact per sentence; the record states what remains, not what changed: pass.
  • pnpm check:knowledge: clean.

Evidence

  • Chromium spec: on main, each case shows two rings while Clear is focused. Here every case shows one.
  • Suites: Selector, the source-build test and the lint-rule test pass (324).
  • Checks: strict lint is clean on the changed files; check:knowledge and check:changesets pass.

Scope

  • No public API: the module is not exported.
  • Public text and artifacts contain no internal context.

Changeset: [fix] patch for @astryxdesign/core.

… too

architecture:interaction-modality INV3: one focus move has one owning
indicator. Item and Token drew their ring with focusWithin
(:has(:focus-visible)), which matches any focused descendant, so a control
in an Item's start or end slot, or a Token's remove button, drew its own
ring and the row or token drew a second around it; a row with no action of
its own rang too.

A new shared style, focusWithinOwner, rings a wrapper only for the direct
child marked data-astryx-focus-owner (FOCUS_OWNER_ATTRIBUTE). Item marks
its invisible button and link (delegation mode keeps focusWithin: the
nested control is the row's sole tab stop by contract); Token marks its
button and link. Other controls ring themselves.

New stories (Item With End Actions, Token Clickable With Remove) and
FocusRingOwner.a11y.chromium.spec.ts: one ring at every tab stop at 1280
and 390 px; it fails on main (two rings while Share or Remove is focused).
focusRings.ts is a shared helper for such specs.
…t the card too

architecture:interaction-modality INV3: one focus move has one owning
indicator. Both cards drew their ring with focusWithin, so a button in
their children (which the docs allow: "Nested interactive elements work
independently") drew its own ring and the card drew a second around it.
Each card now uses focusWithinOwner and marks its own link, button or
checkbox with FOCUS_OWNER_ATTRIBUTE.

SelectableCard gains a With Nested Button story; FocusRingOwner's browser
spec covers both cards at 1280 and 390 px and fails on the previous head.
focusRings ignores a visually hidden control's outline (the cards'
screen-reader-only primaries), which paints nothing a person sees.

Stacked on #8869 (focusWithinOwner).
…, not the thumbnail or trigger too

architecture:interaction-modality INV3: one focus move has one owning
indicator. Thumbnail's image container and the ghost and secondary
Selector and MultiSelector trigger containers rang with focusWithin, so a
Thumbnail's remove button, and a trigger's clear or status button, drew
their own ring and the container a second around it. Each container now
uses focusWithinOwner, and the Thumbnail's Open button and each trigger
button carry FOCUS_OWNER_ATTRIBUTE.

FocusRingOwner's browser spec gains a Thumbnail With Remove case and ghost
and secondary Clearable cases for both selectors, at 1280 and 390 px; they
fail on the previous head (two rings while Remove or Clear is focused).

Stacked on #8872.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 28, 2026
@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 5, 2026 10:24pm 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 5, 2026, 10:25 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.

This change looks ready to merge once #8869 and #8872 land: focusing a Thumbnail's Remove, or the Clear or status button of a ghost or secondary Selector or MultiSelector, now shows a single ring, and the new browser cases fail before the change and pass after it. One optional follow-up on the same lines: the Thumbnail's Open button still keeps the browser's default focus ring inside the container's ring, so a Thumbnail with onClick shows two rings on Open; applying focusOutlineStyles.suppressed to that button, as focusWithinOwner expects, plus an Open-and-Remove browser case would close the rest of that gap.

[Automated review]

aria-label={t('@astryx.thumbnail.open', {accessibleName})}
aria-disabled={isInteractive ? undefined : 'true'}
{...{[FOCUS_OWNER_ATTRIBUTE]: ''}}
{...stylex.props(styles.interactiveButton)}>

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.

Optional, the same gap component:Thumbnail FR4 records: this Open button keeps the browser's default focus ring (outline: auto 1px in Chromium), so focusing Open still paints two rings, the container's focusWithinOwner ring and this one. focusWithinOwner asks for the owner to be paired with focusOutlineStyles.suppressed, which the already-imported helper applies:

{...focusOutlineProps.suppressed(styles.interactiveButton)}>

A Thumbnail story with both onClick and onRemove would let the browser spec cover Open too.

@cixzhang
cixzhang marked this pull request as draft October 30, 2026 21:06
…abled story's doc comment

CodeBunny: focusWithinOwner and FOCUS_OWNER_ATTRIBUTE were reachable from
the published @astryxdesign/core/utils and utils/focusOutline.stylex entry
points, which would make them public API (public-component-api INV12).
They move to src/internal/focusOwner.ts, which no entry point exports, so
nothing new is published and focusOutline.stylex.ts is unchanged from main.
Item.stories: '/** Disabled items. */' goes back above Disabled.
….stylex.ts

The repo's focus-outline-shared lint rule allows rings only in a
focusOutline.stylex file; the internal file keeps that rule and the shared
tokens, and no package entry point exports it.
Follows #8869: focusWithinOwner and FOCUS_OWNER_ATTRIBUTE now come from the
unexported internal/focusOutline.stylex.ts, so nothing new is published.
… ring

Follows #8869: focusWithinOwner and FOCUS_OWNER_ATTRIBUTE come from the
unexported internal/focusOutline.stylex.ts (focusOwnerStyles for the two
selectors' stylex.props lists), so nothing new is published.

@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 the Thumbnail part; the Selector and MultiSelector changes look ready once #8869 and #8872 land. With the image container no longer ringing for Remove, Remove's own focus ring is its only indicator, and over a dark image it is nearly invisible (about 1.08:1 against the image in the default light theme), so keyboard users lose track of focus on thumbnails with showRemoveOn="always" or with both onClick and onRemove. Please keep the container ring for Remove (leave Thumbnail.tsx out of this pull request) until Remove has a focus ring that reads on any image, or add such a ring with design review. Optionally, add ^packages/core/src/internal/focusOutline to the spec's @pr-a11y scope line so changes to the owner ring rerun these browser cases.

[Automated review]

focusOutlineProps.focusWithin(
// Rings for the Open button only; the remove button rings itself
// (`architecture:interaction-modality` INV3).
focusWithinOwnerProps(

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.

Over a dark image this leaves Remove without a visible focus indicator: the container's ring, drawn on the page background, no longer shows for Remove, and Remove's own accent ring paints over the image inside the container's overflow: hidden. With a #222222 image in the default light theme the ring is about 1.08:1 against the image, so focused and resting Remove look the same, and tabbing from Open to Remove makes the only visible ring disappear. component:Thumbnail FR4 asks for one indicator per focus move. Keeping the container ring for Remove until Remove has a ring that reads on any image (or adding one with design review) would avoid the regression.

@@ -1,19 +1,20 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
// @pr-a11y scope ^packages/core/src/(Item|Token|ClickableCard|SelectableCard)/ ^packages/core/src/utils/focusOutline ^apps/storybook/stories/(Item|Token|ClickableCard|SelectableCard)
// @pr-a11y scope ^packages/core/src/(Item|Token|ClickableCard|SelectableCard|Thumbnail|Selector|MultiSelector)/ ^packages/core/src/utils/focusOutline ^apps/storybook/stories/(Item|Token|ClickableCard|SelectableCard|Thumbnail|Selector|MultiSelector)

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.

Optional: the owner ring now lives in internal/focusOutline.stylex.ts, which ^packages/core/src/utils/focusOutline does not match, so a later change to that file alone will not run this spec. Adding ^packages/core/src/internal/focusOutline here would cover it.

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 31, 2026
…and Token resolve the owner module

CodeBunny on #8869:
- In a numbered List, Item wraps a row's button or link in the content cell
  beside the marker, so the owner condition's direct-child :has() missed it
  and the row showed no ring. The cell now carries
  data-astryx-focus-owner-group, and the condition also matches an owner one
  level down inside such a group. A numbered story and a Chromium case
  check one ring for a button row and a link row.
- Swizzled Item and Token import internal/focusOutline.stylex, which Core did
  not export. It is now a ./internal/* entry like internal/touch: reachable
  for Core, Lab and swizzled copies, outside the compatibility promise
  (architecture:public-component-api INV12).
…, privateAttributes/focusOwner.stylex.ts

Per architecture:interaction-modality INV3 and public-component-api INV23:
the private data-astryx-focus-owner attribute, its group attribute and their
selector are written once, in privateAttributes/focusOwner.stylex.ts, which
exports only the shared focusWithinOwner wrapper ring and the props that set
the attributes. Item and Token spread those exports and never write the
attribute; TokenLink takes them through its link props without typing the
name. No package entry exports the module: the ./internal/focusOutline.stylex
entry and its export-sync line are gone. focus-outline-shared allows the
owner module to write its ring.

A source-build test checks the compiled ring sits on the wrapper, keyed to
the marked control's :focus-visible, never :has(...) * on every descendant;
a Chromium case checks a Token inside an Item shows one ring at each stop.
…g-one-owner-cards; the cards spread the focus-owner owner module's ring and props
@cixzhang

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec eb83c39

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 992ec85

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Selector 88.2 kB (+104 B) · 16.4 kB CSS (+55 B) — ✗ · ✓ · ✓
SelectorOption 19.3 kB (0) · 5.8 kB CSS (0) — ✗ · ✓ · ✓
Pagination 98.2 kB (+87 B) · 16.8 kB CSS (+70 B) — — · — · —
2 more components
Component Size LoC Visual · A11y · RTL
PowerSearch 262.7 kB (+74 B) · 22.8 kB CSS (+46 B) — — · — · —
richtext/RichTextEditorToolbar 238.8 kB (+70 B) · 454 B CSS (0) — — · — · —
Visual changes: 8 snapshots in 1 component

A change is a question for the reviewer, not a failure.

Component · story Before After Diff
Selector · Indicator Space Bottom Sheet Narrow End RTL (neutral, light) before frame after frame diff frame
Selector · Indicator Space Bottom Sheet Wide Start (neutral, light) before frame after frame diff frame
Selector · Indicator Space Popover Wide End RTL (neutral, light) before frame after frame diff frame
Selector · Indicator Space Popover Wide End RTL (neutral, dark) before frame after frame diff frame
Selector · Indicator Space Bottom Sheet Narrow End RTL (neutral, dark) before frame after frame diff frame
Selector · Indicator Space Bottom Sheet Wide Start (neutral, dark) before frame after frame diff frame
Selector · Indicator Space Popover Narrow Start (neutral, dark) before frame after frame diff frame
Selector · Indicator Space Popover Narrow Start (neutral, light) before frame after frame diff frame

Package size: @astryxdesign/core 6.63 MB packed (+1.2 kB); no new dependencies.

API changes: none in this pull request

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

Touched components checked; add ci:run-visual, ci:run-a11y 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: the Selector fix works (in Chromium, Clear and the status button on a ghost or secondary Selector now show one focus ring instead of two), but two one-line fixes remain.

  • Newly live check: Selector.tsx:2161-2163 sets outlineWidth and outlineStyle again through pointerRestoredFocus on the element that spreads focusWithinOwner, which architecture:public-component-api INV23 forbids, so spread focusWithinOwner only when !surface.isTriggerFocusRingSuppressed.
  • The INV3 verification row in docs/architecture/interaction-modality.md (line 333) still says "the module does not exist yet", which this pull request makes false, so restate that row's gap as what remains.

Optional: tighten the comments in focusOwner.stylex.ts; the export's "caller styles that follow keep it" reads as permission to set these properties again.

[Automated review]

Comment thread packages/core/src/Selector/Selector.tsx Outdated
Comment on lines 2161 to 2163
variant !== 'input' && focusWithinOwner,
surface.isTriggerFocusRingSuppressed &&
selectorPresentationStyles.pointerRestoredFocus,

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.

pointerRestoredFocus sets outlineWidth and outlineStyle again on the element that spreads focusWithinOwner, which architecture:public-component-api INV23 forbids ("a caller does not set those properties again on the same element"). Gate the owner style instead, so one style writes the outline in each state:

variant !== 'input' && !surface.isTriggerFocusRingSuppressed && focusWithinOwner,
surface.isTriggerFocusRingSuppressed && selectorPresentationStyles.pointerRestoredFocus,

Comment on lines +148 to +150
gap: Item, Token, the clickable and selectable cards, Thumbnail,
MultiSelector, SideNavItem, and ChatComposer's body write their own ring
conditions.

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.

The gap no longer says the module is missing, but the INV3 verification row (line 333) still says "evidence gap for the shared-module cases: the module does not exist yet". Please restate that row's gap as what remains, so the record does not contradict itself.

},
});

/** The wrapper's ring. Spread it first; caller styles that follow keep it. */

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.

Optional: "caller styles that follow keep it" reads as permission for later styles to set these properties, which the comment above and INV23 forbid. Suggested: /** The wrapper's focus ring. */

…V3 verification row says what remains

Per review: focusWithinOwner is spread only when the pointer-restored
focus suppression is off, so pointerRestoredFocus never sets the outline
again on the same element. The INV3 verification row no longer says the
module does not exist. The owner module's export comment no longer reads
as permission to set the outline again.
@cixzhang

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec b3334dd

@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, because the pull request is a draft; its checks run once it is marked ready for review.

In Chromium, tabbing to Clear or to the status button on a ghost or secondary Selector now shows one focus ring instead of two, the trigger still rings once, and the input variant and mouse picks look the same as on main. The two fixes from the previous round (the outline set again in the pointer-restored state, and the stale INV3 verification row) are in.

  • Optional: the first comment sentence in focusOwner.stylex.ts (lines 19-21) runs 27 words over three topics; see the inline suggestion.

[Automated review]

Comment on lines +19 to +21
// Rings only for the wrapper's own marked control, a direct child, so every
// other control inside rings itself and a nested component's owner never rings
// this wrapper. Every condition of each

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.

Optional (comment style): this sentence runs 27 words over three topics, and the block breaks mid-sentence on the next line. Suggested:

// Rings only while the marked control, a direct child, has keyboard focus.
// Other controls inside ring themselves, and a nested owner never rings this
// wrapper.

@cixzhang
cixzhang marked this pull request as ready for review November 5, 2026 20:51

@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 required build and test suites have not run on this head yet (heavy CI was deferred); they run when all jobs are re-run before merge. Typecheck and lint pass.

In Chromium, tabbing to Clear or to the status button on a ghost or secondary Selector shows one focus ring instead of two, the trigger still rings once, and the input variant and mouse picks look the same as on main.

  • Optional: the first comment sentence in focusOwner.stylex.ts (lines 19-21) runs 27 words over three topics; see the inline suggestion.

[Automated review]

Comment on lines +19 to +21
// Rings only for the wrapper's own marked control, a direct child, so every
// other control inside rings itself and a nested component's owner never rings
// this wrapper. Every condition of each

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.

Optional (comment style): this sentence runs 27 words over three topics, and the block breaks mid-sentence on the next line. Suggested:

// Rings only while the marked control, a direct child, has keyboard focus.
// Other controls inside ring themselves, and a nested owner never rings this
// wrapper.

@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 required build and test suites have not run on this head yet (heavy CI was deferred); they run when all jobs are re-run before merge. Typecheck and lint pass.

In Chromium, tabbing to Clear or to the status button on a ghost or secondary Selector shows one focus ring instead of two, the trigger still rings once, and the input variant and mouse picks look the same as on main.

  • Optional: the first comment sentence in focusOwner.stylex.ts (lines 19-21) runs 27 words over three topics; see the inline suggestion.

[Automated review]

Comment on lines +19 to +21
// Rings only for the wrapper's own marked control, a direct child, so every
// other control inside rings itself and a nested component's owner never rings
// this wrapper. Every condition of each

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.

Optional (comment style): this sentence runs 27 words over three topics, and the block breaks mid-sentence on the next line. Suggested:

// Rings only while the marked control, a direct child, has keyboard focus.
// Other controls inside ring themselves, and a nested owner never rings this
// wrapper.

@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 required build and test suites have not run on this head yet (heavy CI was deferred); they run when all jobs are re-run before merge. Typecheck and lint pass.

In Chromium, tabbing to Clear or to the status button on a ghost or secondary Selector shows one focus ring instead of two, the trigger still rings once, and the input variant and mouse picks look the same as on main.

  • Optional: the first comment sentence in focusOwner.stylex.ts (lines 19-21) runs 27 words over three topics; the existing inline suggestion on line 21 has a shorter rewrite.

[Automated review]

@cixzhang

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 992ec85

This branch was successfully deployed

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

Labels

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