Skip to content

[Bug] The pressed overlay never paints: a media-nested :hover out-specifies :active library-wide #5451

Closed

Description

@cixzhang

Description

Every component that pairs the house hover pattern with a :active overlay ships a pressed state that never paints. The two rules both set background-image on the same element, and the hover rule out-specifies the pressed rule — so while the pointer is down, and therefore also hovering, the hover tint is what you see.

This is the same root mechanism as #5442 (StyleX priority buckets emitting specificity that contradicts author intent), but a different instance: there it is :where() lowering a bucket, here it is @media raising one.

Why it happens

StyleX encodes priority by repeating the atomic class and appending :not(#\#) boosts. A pseudo-class nested inside a media query lands in a higher bucket than a bare pseudo-class, so it gets more class repeats:

compiled selector (packages/core/dist/astryx.css) specificity
hover @media (hover: hover){.xmvprkv.xmvprkv.xmvprkv:hover:where(…):not(#\#)×3} (3,4,0)
pressed (Button) .xq8i9tn:active:not(#\#)×3 (3,2,0)
pressed (guarded form) .x7uyq82.x7uyq82:active:where(…):not(#\#)×3 (3,3,0)

Same ID count, so class count decides, and hover wins in both forms. Nothing about the authored source suggests this — the two keys sit next to each other in one backgroundImage object, and the :active one is written last.

Reproduction

Real Chromium against a Storybook build of main (cd1a2da). Hover a control, then mouse.down(), reading getComputedStyle(el).backgroundImage:

Calendar day   rest   none
               hover  linear-gradient(rgba(0,0,0,0.05), rgba(0,0,0,0.05))
               active linear-gradient(rgba(0,0,0,0.05), rgba(0,0,0,0.05))   ← identical

0.05 is --color-overlay-hover; --color-overlay-pressed is 0.098 and never appears.

Independently observed in the ButtonGroup audit on 2026-08-23 (#5389), recorded there as "the background is identical to hover" and attributed to grouping — it is not about grouping.

Affected

Everything using the pattern — Button (all four variants, Button.tsx:208/219/230/245), AvatarGroupOverflow.tsx:105, and any component that adopts it. Button is partly masked from view because its transform: scale(0.98) still fires, so a standalone button visibly depresses and only its tint is missing; a control without the transform (a calendar day, a grouped button) has no pressed feedback at all.

Expected

Pressing a control paints --color-overlay-pressed, per the Pressed row of [Design Conventions § Consistent State Representations].

Notes for whoever picks this up

  • The fix belongs in one place, not per component — the pattern is copied verbatim across the library, so a per-component patch guarantees drift.
  • Nesting :active under @media (hover: hover) to match the bucket would equalise specificity and leave source order to settle it, and it would also drop the pressed state on touch. Worth measuring rather than assuming.
  • Whatever lands wants a Chromium assertion, not a unit test: jsdom has no cascade, which is why this survived a library with a Chromium hover sweep and a Chromium cursor sweep already in CI.

Found by the nightly component auditor while auditing Calendar (rubric v1.8, §4 B4 / §5b D13). Calendar's ledger row links here rather than carrying its own copy of the finding.

Activity

  1. added this to the 0.5.1 milestone on Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions