Repository navigation
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
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
/approve-spec e23bb44 |
|
AI review status for this pull request.
|
There was a problem hiding this comment.
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-colorand a variant's wholeoutlineboth set forfocus-visible, a restingoutline nonefor that variant and a size makesputFocuswrite the variant'soutlinefirst and the whole-partoutline-colorafter 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 thebackgroundshorthand) 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 restingbackgroundshorthand oroutline.
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
backgroundshorthand and a restingoutline(the tests fail on the base and pass on this head; Chromium shows the ring and the hover); false under a restingbackground-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
outlinefor 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-colorand the variant setsoutline(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).
| // 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)) |
There was a problem hiding this comment.
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.
|
/approve-spec 6d94dbe |
There was a problem hiding this comment.
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 focusoutline-color #00aa00, thenoutline none --when variant:ghost+size:smrings small ghost buttons black instead of green, and with a dark-only whole-partoutline-color #ff0000their 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-colororoutline-colorthere still wins over it, so narrow the title to a restingbackgroundshorthand oroutline, 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
backgroundshorthand oroutlinefor 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
outlinebeats a whole-partoutline-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-colorlonghand 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-colororoutline-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.
| !ownFocus.some( | ||
| z => | ||
| sameScope(z) && | ||
| z.mode === y.mode && | ||
| (kebab(z.thing) === 'outline' || | ||
| kebab(z.thing) === kebab(y.thing)), |
There was a problem hiding this comment.
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:
- Ghost focus
outline 2px solid #000000, then small-ghost focusoutline-color #00aa00, thenoutline none --when variant:ghost+size:smbuilds.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. - A dark-only whole-part focus
outline-color #ff0000with 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.
…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.
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 restingbackgroundshorthand oroutlinefor 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, thenoutline none --when variant:ghost+size:sm: small ghost buttons drew the ring in their text color. Now they keep the theme's red.outlineset 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, thenbackground 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
outlinebeats a whole-partoutline-color). A restingbackground-colorlonghand is not covered.Smallest restoration
packages/cli/api/theme-edit/_settings.mjs:withOverlayStatesandwithFocusOutlinewrite 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
packages/cli/api/theme-edit/theme-rest-look-keeps-hover-and-focus.test.mjs(the three variant-and-size cases fail on 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's head)packages/cli/api/theme-editsuite gives the same results as its base.Scope
Components: none (experimental theme editor only)
replay: worse 0 at 6d94dbe
preflight: pass 6d94dbe (CI half pass; review findings are the paired fix's: #13390)