fix(popover): stronger, centralized active-row highlight (UAT finding)
The roving-focus row in every popover menu was barely distinguishable from the menu surface — an accent fill at only 24%, and the recipe was copy-pasted across 5 consumers. Centralize it in PopoverItem (ACTIVE_HIGHLIGHT, applied to every item) and strengthen it: accent/35 fill + a 1px inset accent ring for a defined edge that reads across all 6 schemes in both themes. Consumers no longer carry the recipe. Uses the now-working `bg-accent/NN` / `ring-accent/NN` utilities (v4 does the opacity modifier via color-mix) instead of the old hand-written color-mix arbitrary value the v3 no-op forced. Verified in-browser: fill + inset ring render on the active item, dark and light.
This commit is contained in:
@@ -223,13 +223,18 @@ type ItemRole = "menuitem" | "menuitemradio" | "menuitemcheckbox" | "option";
|
||||
* one exclusive choice, `menuitemcheckbox`+`checked` when several can be on at once,
|
||||
* `option`+`selected` for a listbox choice, plain `menuitem` for an action.
|
||||
*
|
||||
* The active (roving) item carries `data-active` — style the highlight off THAT, not `:focus-visible`:
|
||||
* The active (roving) item carries `data-active`, and the highlight is applied HERE for every item
|
||||
* (see ACTIVE_HIGHLIGHT) — consumers don't add it. It's driven off `data-active`, not `:focus-visible`:
|
||||
* a click-opened menu focuses the first item programmatically, which does NOT reliably trip the
|
||||
* focus-visible heuristic, so a `:focus-visible` highlight can stay invisible until the first arrow
|
||||
* key. The recommended recipe is an accent tint — and note `bg-accent/NN` does NOT work here (the
|
||||
* theme's `--accent` is a hex var, and Tailwind v3 can't inject alpha into it), so use a color-mix
|
||||
* arbitrary value like the app's own glass idiom:
|
||||
* `data-active:bg-[color-mix(in_srgb,var(--accent)_24%,transparent)] data-active:text-fg`. */
|
||||
* key. (Since the Tailwind v4 migration `bg-accent/NN` works — v4 does the opacity modifier via
|
||||
* color-mix — so the recipe no longer needs a hand-written color-mix arbitrary value.) */
|
||||
// Applied to EVERY PopoverItem so the roving-focus row is clearly visible across all schemes: an
|
||||
// accent fill plus a 1px inset accent ring for a defined edge. (The previous per-consumer 24% fill
|
||||
// alone read as barely-there — a real UAT finding, 2026-08-08.)
|
||||
const ACTIVE_HIGHLIGHT =
|
||||
"data-active:bg-accent/35 data-active:text-fg data-active:ring-1 data-active:ring-inset data-active:ring-accent/60";
|
||||
|
||||
export function PopoverItem({
|
||||
children,
|
||||
onSelect,
|
||||
@@ -286,7 +291,7 @@ export function PopoverItem({
|
||||
tabIndex={active ? 0 : -1}
|
||||
data-active={active ? "true" : undefined}
|
||||
disabled={disabled}
|
||||
className={className}
|
||||
className={`${ACTIVE_HIGHLIGHT}${className ? ` ${className}` : ""}`}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user