Skip to content

fix(cli): a resting look gives back Core's own hover and press, keeps a state the theme sets, and keeps the theme's own focus outline properties - #13293

Closed
josephfarina wants to merge 2 commits into
feature/theme-editorfrom
josephfarina/editor-rest-look-keeps-own-states
Closed

josephfarina wants to merge 2 commits into
feature/theme-editorfrom
josephfarina/editor-rest-look-keeps-own-states

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the cases from #13235.

User impact

astryx experimental theme editor set:

  • A resting background set with no --when replaced a hover or press background the theme had set for one variant (a ghost button's hover gradient) with Core's overlay. Under a resting background with no --when, that variant's own state now keeps what the theme set.
  • The hover and press a resting background shorthand gives back now come from Core's own rule (background-image: revert-layer in the setting's scope), so they keep Core's conditions: no press layer on a disabled part, no hover layer stuck after a tap on a touch screen, and a combined --when scope (variant:ghost+size:sm) gets both back.
  • Once a part had any focus outline setting, a resting outline gave the focus state nothing back. So outline-color … --state focus-visible and then outline none left buttons with no visible keyboard focus. Now each outline property the theme sets for focus keeps its value (for the whole part, or that variant, also under a resting outline scoped to that variant and a size), and Core's focus outline style and width still come back. A state set for one mode keeps that mode only; the other mode still gets Core's back.

Not split: every change is in the two restore helpers that #13235's findings name, and over 40% of the lines are the test rows for them.

Smallest restoration

  • packages/cli/api/theme-edit/_settings.mjs: withOverlayStates writes revert-layer for each restored state in the setting's own scope and skips a state the theme sets for that scope or a wider one (a size, density or elevation piece never rules a rendered button out, since Core's overlay does not change with them); withFocusOutline keeps only the outline properties the theme sets for focus.
  • packages/cli/api/theme-edit/theme-rest-look-keeps-hover-and-focus.test.mjs: each case (the disabled press, a combined scope, touch, a variant's own hover, the theme's own focus outline color, and one set for one mode).
  • .changeset/experimental-theme-rest-look-keeps-own-states.md: the release note.

Evidence

  • packages/cli/api/theme-edit/theme-rest-look-keeps-hover-and-focus.test.mjs
  • The whole packages/cli/api/theme-edit suite gives the same results as its base.

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 bdb77f6

preflight: pass bdb77f6 (CI half pass; review findings are the paired fix's: #13357)

… a state the theme sets, and keeps the theme's own focus outline properties

Fixes the cases from #13235: a resting background with no --when replaced a hover background the theme set for one variant with Core's overlay; the written-back press had no enabled guard, a combined --when got no hover or press back, and the written-back hover had no (hover: hover) condition; and any focus outline setting stopped Core's focus outline from coming back, so outline-color on focus then outline none left no visible keyboard focus. Each restored state now writes background-image: revert-layer in the setting's own scope, so Core's own rule shows through.
@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 12:40pm 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
@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, 1:49 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.

Waiting on an engineering owner: no current spec record says what the theme editor should give back under a resting background or outline, so approval waits on an engineering owner commenting /approve-spec <full head SHA> on this pull request (the author may do so if they are an engineering owner). The changes otherwise fix the cases from #13235: Core's hover and press come back under Core's own disabled and touch conditions, a variant's own hover is kept, and the keyboard focus ring returns.

One fix is needed whatever the ruling:

  • A focus outline color the theme sets for one variant is replaced by Core's under a resting outline scoped to that variant plus a size (outline-color '#ff0000' --state focus-visible --when variant:ghost, then outline none --when variant:ghost+size:sm, leaves small ghost buttons with Core's ring), because withFocusOutline finds no variant in the stored scope size:sm+variant:ghost and putFocus counts only a setting with no --when as the theme's own (packages/cli/api/theme-edit/_settings.mjs:7123-7128); handle that case and add a test.
Claims and files checked

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

Changeset claims:

  • A resting look keeps what the theme sets for a part's own states: verified for the same scope, a wider one, and one variant under a whole-part background (tests, browser); one focus case fails (finding above).
  • A resting background gives hover and press back from Core under Core's conditions, with no press on a disabled part and no hover left after a tap: verified (the head writes revert-layer; Core's Button and overlay styles carry the guards; a touch-emulated tap leaves the overlay on the base and none on the head).
  • A combined --when scope keeps both states: verified (its test fails on the base and passes on the head).
  • A state background the theme sets for that scope, a wider one, or one variant under a whole-part background stays as set in any order: verified (tests; the theme is compiled from all settings at once).
  • Large or raised buttons get hover and press back: verified on the head; the base already restored them as fixed values.
  • A focus outline property the theme sets is kept under a resting outline none, and Core's style and width come back: verified for whole-part settings (test, browser); false for one variant's color under a resting outline scoped to that variant plus a size (finding).
  • A state set for one mode keeps that mode and the other mode gets Core's: verified (focus test; compiled hover output).

Description claims:

  • Fixes the cases from #13235: verified for the variant hover and the focus outline cases.
  • A whole-part resting background replaced a variant's own hover, which is now kept: verified (tests fail on the base and pass on the head; browser).
  • Restored hover and press come from Core's own rule through revert-layer in the setting's scope, with the disabled, touch and combined-scope behavior: verified.
  • Any focus outline setting stopped the focus outline from coming back; each property the theme sets is now kept for the whole part or that variant: the base defect is verified; the variant part fails under a combined resting scope (finding).
  • The overlay restore skips states the theme sets for that scope or a wider one, and size, density and elevation never rule a button out: verified in code.
  • The focus restore keeps only the outline properties the theme sets for focus: verified in code, with the gap above.
  • The new tests cover each listed case: verified; the eight new tests and the changed one fail on the base and pass on the head.
  • The whole theme-edit suite matches its base: not rerun in full; 40 related test files pass on the head.
  • The change is limited to the experimental theme editor, adds no public API and carries no internal context: verified.

Files:

  • .changeset/experimental-theme-rest-look-keeps-own-states.md: an [experimental] patch note as the release process requires; the focus sentence claims more than the code does (finding).
  • packages/cli/api/theme-edit/_settings.mjs: the variant focus color case (finding); hover backgrounds in overlapping scopes, such as one variant and one size, still mix (non-blocking).
  • packages/cli/api/theme-edit/theme-rest-look-keeps-hover-and-focus.test.mjs: clear; the disabled and touch tests check only that the overlay value is absent (non-blocking).

Automated review (maintainer link)

…utline scoped to that variant and a size

Review finding: with outline-color set for variant:ghost on focus, a resting outline none --when variant:ghost+size:sm gave small ghost buttons Core's ring color. The restore now reads the variant a combined scope names and counts a focus setting whose scope the written one holds as the theme's own.
@josephfarina

Copy link
Copy Markdown
Contributor Author

Covers the theme-editor reading this pull request records (the owner's ruling): under a resting background or outline, the editor gives back Core's own hover, press and focus outline (under Core's disabled and touch conditions), and keeps any state value the theme set itself for that scope or wider, for one variant, or for one mode in that mode.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec bdb77f6

@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 engineering owner's /approve-spec for this head settles the direction, but a theme's own focus or hover value set for a wider scope is still lost under a resting setting for a variant plus a size:

  • A focus outline color the theme sets for one variant (or one size) is not kept under a resting outline for that variant and a size, because the resting outline: none outweighs the theme's wider focus rule by order, so small ghost buttons draw the ring in their text color while the new test passes by checking only that Core's color is absent (packages/cli/api/theme-edit/_settings.mjs:7129-7135).
  • With a whole outline the theme sets for the ghost focus state and then outline none --when variant:ghost+size:sm, a focused small ghost button has no focus ring at all, since nothing is written at the resting scope and the theme's outline loses to the resting rule the same way (_settings.mjs:7128-7135).
  • Miss: a hover background the theme sets for one variant is lost under a resting background for that variant and a size, so small ghost buttons show no hover in either setting order, contrary to the release note's "for that scope or a wider one … stays as set in any order" (_settings.mjs:7075-7083).

One fix covers all three: when the theme's own state value is for a wider scope than the resting setting, write that value into the resting scope's state rule instead of skipping it, and add tests that assert the theme's value in the [data-size="sm"][data-variant="ghost"] focus and hover rules. The ruling covers this head only, so an engineering owner records it again with /approve-spec <new head SHA> after the push.

Claims and files checked

Review mode: same-head; reason: none

  • changed rules (0): none

Release note claims:

  • A resting look keeps what the theme sets for a part's own states: holds for the same scope and the whole part; false for a wider scope plus a piece (all three findings).
  • A resting background gives hover and press back from Core under Core's conditions, with no press on a disabled part and no hover left after a tap: verified (revert-layer in the setting's scope; Core's overlay rule carries the enabled guard, the hover-capable media and the coarse-pointer press; Chromium shows the overlay on a hovered ghost button and none on a disabled one or after a tap).
  • A combined --when scope keeps both states: verified when the theme sets no hover of its own (test); false with a variant hover the theme sets (third finding).
  • A hover or press background the theme sets for that scope or a wider one, or for one variant under a whole-part background, stays as set in any order: verified for the same scope and the whole part (tests; compiled output); false for a variant hover under a variant-and-size resting background, in both orders (third finding).
  • Large or raised buttons get hover and press back: verified (test).
  • A focus outline property the theme sets for the whole part or one variant is kept under a resting outline none, including one scoped to that variant and a size: verified for the whole part (Chromium: red ring where the base drew none) and the same variant; false under a variant-and-size resting outline (first finding).
  • Core's focus outline style and width still come back, so keyboard focus stays visible: false when the theme sets the variant's whole focus outline (second finding).
  • A state set for one mode keeps that mode only: verified for whole-part settings (test).
  • The note is an experimental patch for the CLI: verified.

Description claims:

  • Fixes the cases from #13235: verified for a variant hover under a whole-part background and for whole-part focus settings; not for wider-scope cases (findings).
  • A whole-part resting background replaced a variant's own hover, which is now kept: verified (tests; compiled output).
  • Restored hover and press come from Core's own rule through revert-layer in the setting's scope, with the disabled, touch and combined-scope behavior: verified (compiled output, Core's overlay rule, Chromium, tests), with the third finding for a combined scope under a variant hover.
  • Any focus outline setting stopped the focus outline from coming back; each property the theme sets for focus now keeps its value for the whole part or that variant, also under a resting outline for that variant and a size, and Core's style and width come back: the base defect is verified (no ring on the base); the variant-and-size part is false (first and second findings).
  • A state set for one mode keeps that mode and the other mode gets Core's: verified for whole-part settings (test).
  • The overlay restore skips a state the theme sets for that scope or a wider one, and size, density and elevation never rule a button out: verified in code; skipping a wider scope loses the value (third finding).
  • The focus restore keeps only the outline properties the theme sets for focus: verified in code, with the first two findings.
  • The test file covers each case: 13 of 13 pass; the variant-and-size focus test asserts only an absence (first finding).
  • The whole theme-edit suite gives the same results as its base: not rerun in full; the changed test file passes on this head.
  • Every change is in the two restore helpers and much of the change is tests: verified (175 of 339 changed lines are tests).
  • The change is limited to the experimental theme editor, adds no public API and carries no internal context: verified.

Files:

  • .changeset/experimental-theme-rest-look-keeps-own-states.md: an experimental patch note as the release process requires; its focus and hover sentences claim more than holds (findings).
  • packages/cli/api/theme-edit/_settings.mjs: all three findings; hover backgrounds in overlapping scopes, such as one variant and one size, can still mix (non-blocking).
  • packages/cli/api/theme-edit/theme-rest-look-keeps-hover-and-focus.test.mjs: the variant-and-size focus test asserts only an absence (first finding); the disabled and touch tests check only that the overlay value is absent (non-blocking).

Automated review (maintainer link)

.split('+')
.every(piece => held.includes(piece))),
);
if (own.some(y => !y.mode)) return;

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: returning here keeps the theme's value only when the theme's focus rule outweighs the resting rule. With outline-color '#ff0000' --state focus-visible --when variant:ghost, then outline none --when variant:ghost+size:sm, .astryx-button[data-variant="ghost"]:focus-visible and .astryx-button[data-size="sm"][data-variant="ghost"] weigh the same and the resting rule comes later, so outline: none resets the color to currentcolor: small ghost buttons draw the ring in their text color. With a whole outline set for ghost focus, nothing is written at the resting scope and small ghost buttons lose the ring entirely. When the theme's own value is for a scope wider than when, write that value at when instead of returning (the compiler already copies a whole-part value this way), and assert it in the [data-size="sm"][data-variant="ghost"]:focus-visible rule.

piecesOf(y.when).every(p => scope.includes(p)) &&
partsOf(ctx, y).includes(target),
);
if (setByTheme.some(y => !y.mode)) continue;

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): the same gap for hover and press. With background '#eeeeee' --state hover --when variant:ghost, then background transparent --when variant:ghost+size:sm, this skips the hover, but the resting background: transparent on [data-size="sm"][data-variant="ghost"] weighs the same as the ghost hover rule and comes later, so small ghost buttons show no hover at all. Write the theme's own state background at the resting scope when it is set for a wider one.

@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-keeps-own-states branch November 22, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — bdb77f69 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