Repository navigation
fix(Selector): a ghost or secondary trigger's clear and status buttons ring themselves, not the trigger too - #8874
Conversation
… 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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
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)}> |
There was a problem hiding this comment.
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.
…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.
…g-one-owner-cards
Follows #8869: focusWithinOwner and FOCUS_OWNER_ATTRIBUTE now come from the unexported internal/focusOutline.stylex.ts, so nothing new is published.
…-owner-thumbnail-selector
… 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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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) | |||
There was a problem hiding this comment.
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.
…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
…g-one-owner-cards; the cards spread the focus-owner owner module's ring and props
|
/approve-spec eb83c39 |
PR Analysis Report🔎 Preview ·
|
| 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.
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
There was a problem hiding this comment.
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-2163setsoutlineWidthandoutlineStyleagain throughpointerRestoredFocuson the element that spreadsfocusWithinOwner, whicharchitecture:public-component-apiINV23 forbids, so spreadfocusWithinOwneronly 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]
| variant !== 'input' && focusWithinOwner, | ||
| surface.isTriggerFocusRingSuppressed && | ||
| selectorPresentationStyles.pointerRestoredFocus, |
There was a problem hiding this comment.
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,| gap: Item, Token, the clickable and selectable cards, Thumbnail, | ||
| MultiSelector, SideNavItem, and ChatComposer's body write their own ring | ||
| conditions. |
There was a problem hiding this comment.
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. */ |
There was a problem hiding this comment.
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.
|
/approve-spec b3334dd |
There was a problem hiding this comment.
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]
| // 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 |
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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]
| // 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 |
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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]
| // 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 |
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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]
|
/approve-spec 992ec85 |
























Part of #8850, for
Selectoronly. 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
Selectorsees two rings: the button's, and a second around the whole trigger. Now each tab stop shows one ring.Problem and solution fit
focusWithin, which matches any focused descendant, including the clear and status buttons.focusWithinOwnerand the trigger button spreadsfocusOwnerProps, both from the new owner moduleprivateAttributes/focusOwner.stylex.ts. The box rings only while its own trigger button has keyboard focus. Theinputvariant, which draws focus as a border, is unchanged.data-astryx-focus-owneror its selector, asarchitecture:interaction-modalityINV3 names it. Thefocus-outline-sharedlint 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.jsand its test: the owner module may write the ring.docs/architecture/interaction-modality.mdINV3: the implementation gap no longer says the module is missing, and no longer lists Selector.FocusRingOwner.a11y.chromium.spec.ts(new) withfocusRings.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
pnpm check:knowledge: clean.Evidence
check:knowledgeandcheck:changesetspass.Scope
Changeset:
[fix]patch for@astryxdesign/core.