Skip to content

fix(cli): a variant's own hover or focus outline stays under a resting background shorthand or outline for that variant and a size - #13357

Closed
josephfarina wants to merge 2 commits into
josephfarina/editor-rest-look-keeps-own-statesfrom
josephfarina/editor-rest-look-wider-scope
Closed

josephfarina wants to merge 2 commits into
josephfarina/editor-rest-look-keeps-own-statesfrom
josephfarina/editor-rest-look-wider-scope

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the review findings on #13293 (sits directly on it).

User impact

astryx experimental theme editor set: a hover background or a focus outline the theme set for one variant was lost under a resting background shorthand or outline for that variant and a size, because the resting rule is written later at the same weight.

  • outline-color '#ff0000' --state focus-visible --when variant:ghost, then outline none --when variant:ghost+size:sm: small ghost buttons drew the ring in their text color. Now they keep the theme's red.
  • A whole outline set for the ghost focus state, then the same resting outline: small ghost buttons had no focus ring at all. Now they keep the theme's outline.
  • background '#eeeeee' --state hover --when variant:ghost, then background transparent --when variant:ghost+size:sm: small ghost buttons showed no hover. Now they keep the theme's hover.

The restore writes the theme's own wider values again at the resting scope, once for all outline properties, the widest first so the nearest one wins (a variant's whole outline beats a whole-part outline-color). A resting background-color longhand is not covered.

Smallest restoration

  • packages/cli/api/theme-edit/_settings.mjs: withOverlayStates and withFocusOutline write a wider-scope state value at the resting scope.
  • packages/cli/api/theme-edit/theme-rest-look-keeps-hover-and-focus.test.mjs: each case asserts the theme's value in the [data-size="sm"][data-variant="ghost"] hover and focus rules, plus whole-part guards.
  • .changeset/experimental-theme-rest-look-wider-scope.md: the release note.

Evidence

Scope

Components: none (experimental theme editor only)

  • 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.

replay: worse 0 at 6d94dbe

preflight: pass 6d94dbe (CI half pass; review findings are the paired fix's: #13390)

…a narrower resting setting

Review findings on #13293: a focus outline or hover background the theme set for one variant (or the whole part) lost, by order at the same weight, to a resting setting for that variant and a size. The restore now writes the theme's own wider value again at the resting scope, the widest first so the nearest wins.
@vercel

vercel Bot commented Nov 21, 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 21, 2026 3:10pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 21, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec e23bb44

@astracat-bot

astracat-bot Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Nov 21, 2026, 3:29 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.

Changes requested. The restore now brings back hover and keyboard focus for small ghost buttons in the three cases reported on #13293, and the engineering owner's /approve-spec for this head settles the direction. Two things still need fixing:

  • With a whole-part outline-color and a variant's whole outline both set for focus-visible, a resting outline none for that variant and a size makes putFocus write the variant's outline first and the whole-part outline-color after it in the restored rule, so small ghost buttons get a red ring where the theme draws a black one (packages/cli/api/theme-edit/_settings.mjs:7157-7169).
  • The title and release note claim more than the change covers: a resting background-color (rather than the background shorthand) still drops a variant's hover on small ghost buttons, and the whole-part cases already held on the base, so narrow the wording to one-variant values under a resting background shorthand or outline.

Writing the wider focus values once, widest first across all outline properties, with a test that checks which value wins, would cover the first point.

Claims and files checked

Review mode: full; reason: no-earlier-review

Release note claims:

  • A hover background or focus outline set for one variant now stays under a resting setting for that variant and a size: verified for a resting background shorthand and a resting outline (the tests fail on the base and pass on this head; Chromium shows the ring and the hover); false under a resting background-color (finding).
  • The same holds for a whole-part value under a one-variant resting setting: this already held on the base, where both whole-part tests pass (finding).
  • Before, the resting rule outweighed the theme's value by order, so small ghost buttons lost the hover or focus ring: verified for the variant cases.
  • The note is an experimental patch for the CLI: verified.

Description claims:

  • Small ghost buttons drew the ring in their text color in the outline-color case and now keep the theme's red: verified (test, built CSS).
  • A whole outline for ghost focus now survives a resting outline for ghost and small: verified (test; Chromium shows the black dotted ring).
  • A ghost hover now survives a resting background for ghost and small: verified (test; Chromium shows the hover color).
  • The restore writes the theme's wider value again at the resting scope, widest first so the nearest wins: the write is verified; the nearest does not win when the whole part sets outline-color and the variant sets outline (finding).
  • The three variant-and-size cases fail on the base: verified (exactly those three fail there).
  • The whole theme-edit suite gives the same results as its base: not rerun in full; 21 related test files give identical results on both.
  • No new public API, default or interaction model, and no internal context: verified.

Files:

  • .changeset/experimental-theme-rest-look-wider-scope.md: claims more than the change covers (finding).
  • packages/cli/api/theme-edit/_settings.mjs: the focus write-order defect (finding); two equally wide scopes are restored in setting order rather than the theme's own order (non-blocking).
  • packages/cli/api/theme-edit/theme-rest-look-keeps-hover-and-focus.test.mjs: the new tests check that the value is present, not that it wins (non-blocking).

Automated review (maintainer link)

// resting scope, the widest first so the nearest wins.)
for (const y of setByTheme
.filter(z => !sameScope(z))
.sort((a, b) => piecesOf(a.when).length - piecesOf(b.when).length))

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: two equally wide scopes keep their setting order here. Example: background '#dddddd' --state hover --when size:sm, then background '#eeeeee' --state hover --when variant:ghost, then background transparent --when variant:ghost+size:sm. The copy writes #eeeeee. Without the resting background, small ghost buttons hover #dddddd, because the theme writes size rules after variant rules.

…st, so the nearest wins

Review finding: with a whole-part outline-color and a variant's whole outline both set for focus, the restore under a variant-and-size resting outline wrote the variant's outline before the whole part's color, so small ghost buttons drew the whole part's color. The wider values are now written once for all outline properties, widest first. The release note now names what it covers: one variant's values under a resting background shorthand or outline.
@josephfarina josephfarina changed the title fix(cli): a state value the theme sets for a wider scope stays under a narrower resting setting fix(cli): a variant's own hover or focus outline stays under a resting setting for that variant and a size Nov 21, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 6d94dbe

@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. This head fixes the ring color the earlier review reported: with a whole-part outline-color and a variant's whole outline, small ghost buttons now draw the variant's ring, and an engineering owner's /approve-spec for this head covers the direction. Two things still need fixing:

  • Miss: when the resting scope sets its own focus color, the copied wider value replaces it, so a ghost focus outline 2px solid #000000, then a small-ghost focus outline-color #00aa00, then outline none --when variant:ghost+size:sm rings small ghost buttons black instead of green, and with a dark-only whole-part outline-color #ff0000 their dark-mode ring turns from green on the base to red (packages/cli/api/theme-edit/_settings.mjs:7217-7231).
  • The title says a variant's hover or focus outline stays "under a resting setting" for that variant and a size, but a resting background-color or outline-color there still wins over it, so narrow the title to a resting background shorthand or outline, as the release note now says.

Skipping a wider value whenever the resting scope sets that property (or a shorthand covering it) with no mode or the same mode, and writing a wider outline as its longhands, would cover the first point; a test per case that checks which color wins would keep it fixed.

Claims and files checked

Review mode: incremental; reason: none

Release note claims:

  • A hover background or focus outline the theme sets for one variant now stays under a resting background shorthand or outline for that variant and a size: verified (tests fail on the base and pass on this head; Chromium shows the theme's ring).
  • Before, the resting rule won by order, so small ghost buttons lost the theme's hover or focus ring: verified (base CSS; Chromium shows no ring).
  • The note is an experimental patch for the CLI: verified.

Description claims:

  • In the outline-color case small ghost buttons now keep the theme's red focus color: verified (test, built CSS).
  • With a whole ghost focus outline, small ghost buttons now keep the theme's outline: verified (test; Chromium shows the black dotted ring).
  • With a ghost hover background, small ghost buttons now keep the theme's hover: verified (test; built CSS).
  • The wider values are written once for all outline properties, widest first, so a variant's whole outline beats a whole-part outline-color: verified for wider scopes (the new test fails on the previous revision and passes here); false when the resting scope sets its own focus color (finding).
  • A resting background-color longhand is not covered: verified.
  • The three variant-and-size cases fail on the base pull request's head: verified (they fail there, as does the new fourth case).
  • The whole theme-edit suite gives the same results as its base: partly verified (the 50 theme-edit test files that set focus, outline or hover states match apart from the new tests).
  • No new public API, default or interaction model, and no internal context: verified.

Title:

  • A variant's own hover or focus outline stays under a resting setting for that variant and a size: false for a resting background-color or outline-color (finding).

Files:

  • .changeset/experimental-theme-rest-look-wider-scope.md: clear; it now matches the tests.
  • packages/cli/api/theme-edit/_settings.mjs: the same-scope focus override (finding); equally wide scopes restored in setting order and a repeated result note for a scope the person never set (non-blocking).
  • packages/cli/api/theme-edit/theme-rest-look-keeps-hover-and-focus.test.mjs: clear; the new order test covers the earlier finding, and no test sets a focus value for the resting scope itself.

Automated review (maintainer link)

Comment on lines +7218 to +7223
!ownFocus.some(
z =>
sameScope(z) &&
z.mode === y.mode &&
(kebab(z.thing) === 'outline' ||
kebab(z.thing) === kebab(y.thing)),

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.

Blocking (Miss): this skip treats a same-scope value as covering a wider one only when it sets the very same property, or outline, in the same mode. Two cases break:

  1. Ghost focus outline 2px solid #000000, then small-ghost focus outline-color #00aa00, then outline none --when variant:ghost+size:sm builds .astryx-button[data-size="sm"][data-variant="ghost"]:focus-visible { outline-color: #00aa00; outline: 2px solid #000000; }, so the ring is black where the theme draws green.
  2. A dark-only whole-part focus outline-color #ff0000 with the same small-ghost green writes a dark-mode red copy at the same weight after the green, so in dark mode the ring turns from green (base) to red.

Skip y when a same-scope setting with no mode or the same mode sets y.thing or a shorthand covering it (as withOverlayStates does for a no-mode setting at line 7086), and write a wider outline as its longhands minus the ones the resting scope sets. A test per case that checks which color wins would keep it fixed.

@josephfarina josephfarina changed the title fix(cli): a variant's own hover or focus outline stays under a resting setting for that variant and a size fix(cli): a variant's own hover or focus outline stays under a resting background shorthand or outline for that variant and a size Nov 21, 2026
josephfarina added a commit that referenced this pull request Nov 21, 2026
…itten by a wider one

Review findings on #13357: with a ghost focus outline, a small-ghost focus outline-color and a resting outline none for small ghosts, the wider outline was copied over the small ghost's own color (and a dark-only whole-part color over it in dark mode); and a focus color set for a combined state (focus-visible+active) was copied to the plain focus state. A wider value is now copied only for the plain focus state, and only where the resting scope sets no focus outline of its own in that mode.
@josephfarina

Copy link
Copy Markdown
Contributor Author

Folded into #13464, which returns #13235 against main with this fix included.

@github-actions
github-actions Bot deleted the josephfarina/editor-rest-look-wider-scope branch November 22, 2026 06:04

This branch was successfully deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant