Skip to content

fix(web): filter toggle hover as border, not background (#1460) - #1461

Merged
cliffhall merged 2 commits into
v2/mainfrom
fix/1460-filter-toggle-hover-border
Jun 13, 2026
Merged

cliffhall merged 2 commits into
v2/mainfrom
fix/1460-filter-toggle-hover-border

Conversation

@cliffhall

@cliffhall cliffhall commented Jun 13, 2026 •

Copy link
Copy Markdown
Member

Closes #1460

Problem

The Filter by … toggle buttons on the Logging, History, and Network screens gave no feedback when toggled off: their hover background and their active (on) background were the same token (--mantine-primary-color-light). Clicking a toggled-on button to turn it off while the cursor was still over it looked like nothing happened — the identical hover background immediately replaced the active one.

Fix

  • Shared FilterToggleButton element (components/elements/FilterToggleButton/) now used by LogControls, NetworkControls, and MessageDirectionFilter, replacing the duplicated UnstyledButton + inline bg={active ? "var(--mantine-primary-color-light)" : undefined} in each of the three. The toggle styling lives in one place now.
  • New filterToggle theme variant (theme/UnstyledButton.ts) + .filter-toggle rules (App.css):
    • Hover → thin border (--inspector-brand-primary), reserved via a permanent 1px solid transparent border so it doesn't shift layout.
    • Active → filled background, keyed off aria-pressed="true".
    • The two states are now visually distinct, so toggling off is immediately visible even under the cursor.
  • The shared .list-item selectable rows (Prompts/Apps/Tools/Resources lists, sectionHeader Groups) are untouched — they keep their hover-fill since they're single-select/navigation rows, not toggles.
  • Added aria-pressed to the Logging level toggles (previously missing; the Network/Direction toggles already had it).

Screencapture

filter-toggle-feedback.mov

Tests

  • New FilterToggleButton unit tests + stories (active/inactive aria-pressed, toggle-on, toggle-off).
  • Added an aria-pressed reflection test to LogControls, and a clear-button test to NetworkControls (keeps per-file coverage ≥ 90% after the line-count shrank).
  • npm run validate ✅ · npm run test:storybook ✅ (353 passed).

Note: the active-fill/hover-border are CSS-only (applied in real browsers); happy-dom unit tests assert the behavior via aria-pressed, and the Storybook play functions run in real Chromium.

🤖 Generated with Claude Code

The Logging/History/Network filter toggles used the same
--mantine-primary-color-light background for both their hover and their
active (toggled-on) state, so clicking a button to turn it off while the
cursor was still over it looked like a no-op — the hover background
masked the removal of the active background.

- Add a shared FilterToggleButton element used by LogControls,
  NetworkControls, and MessageDirectionFilter, replacing the duplicated
  UnstyledButton + inline `bg={active ? … : undefined}` in each.
- Add a `filterToggle` UnstyledButton theme variant + `.filter-toggle`
  rules: hover is now a thin border (reserved via a transparent 1px
  border so it doesn't shift layout); the active state is the filled
  background, keyed off `aria-pressed="true"`.
- This leaves the `.list-item` selectable rows (Prompts/Apps/Tools/
  Resources lists, section headers) untouched — they keep their
  hover-fill since they aren't toggles.
- Add `aria-pressed` to the Logging level toggles (previously missing).

Tests + stories cover the active/hover distinction via aria-pressed for
FilterToggleButton and all three controls.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cliffhall cliffhall added the v2 Issues and PRs for v2 label Jun 13, 2026
…1460)

The previous attempt set the reserved `1px solid transparent` border via
the theme's `styles` callback, which Mantine emits as an *inline* style.
Inline styles outrank stylesheet `:hover` rules, so
`.filter-toggle:hover { border-color }` never applied — hovering showed
no border at all (verified in a real browser via Playwright).

Move the border (and border-radius) out of the inline theme styles into
the `.filter-toggle` class in App.css, so `:hover` can override the
transparent border-color. The active fill (`[aria-pressed="true"]`) was
already correct.

Verified with real Playwright page.hover: inactive+hover now shows a
1px --inspector-brand-primary border, active shows the fill, active+hover
shows both, all distinct. Story play functions assert the active fill and
the reserved transparent border (the hover border can't be asserted in the
synthetic-event test runner, so it's documented as Playwright-verified).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member Author

@claude review

@claude

claude Bot commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @cliffhall's task in 1m 28s —— View job


Review: filter toggle hover as border, not background (#1460)

  • Read the diff and changed files
  • Review for correctness, best practices, repo conventions
  • Post review feedback

Solid, well-scoped fix. The root cause (hover-fill and active-fill sharing --mantine-primary-color-light, so toggling-off under the cursor looked like a no-op) is correctly addressed by making the two states visually orthogonal: hover → border, active → fill. The extraction into a single FilterToggleButton element removes three copies of the same UnstyledButton + inline-bg snippet, and the inline comments explaining why the transparent border must live in the stylesheet (not as an inline style that would outrank :hover) are genuinely helpful for the next maintainer.

Correctness ✅

  • CSS specificity is clean: .filter-toggle:hover (border-color) and .filter-toggle[aria-pressed="true"] (background-color) are both (0,2,0) but set disjoint properties, so they compose rather than conflict. Active+hover yields border+fill, which is fine.
  • The reserved 1px solid transparent border + box-sizing: border-box (Mantine default) means hover introduces no layout shift. ✓
  • --inspector-brand-primary (= --mantine-primary-color-filled) and --mantine-primary-color-light are both theme-adaptive, so no separate dark-mode rule is needed here (unlike .list-item, whose dark override is actually redundant — same value — but that's pre-existing and out of scope).
  • Convention compliance is good: styling lives in the theme variant + App.css (pseudo-selectors only), ToggleLabel is a Text.withProps subcomponent constant, no inline styles, no raw hex. Adding aria-pressed to the Logging toggles (previously missing) is a nice accessibility win and gives the unit tests a real handle.

Minor / optional (non-blocking)

  • Active + hover both lit. Hovering an active button shows the border and the fill simultaneously. That reads fine, but if you wanted the hover affordance reserved purely for the "this will change" cue, you could suppress the border when pressed (.filter-toggle:not([aria-pressed="true"]):hover). Purely a taste call — current behavior is reasonable.
  • color: string prop is free-form. Callers pass trusted tokens (LEVEL_COLORS[...].c, etc.), so this is fine; just flagging that it accepts any string rather than a constrained union.
  • NetworkControls clear-button test is tangential to this change (added to backfill the coverage lost when the file shrank). Legitimate, just noting it isn't testing the toggle behavior itself.
  • Storybook caveat is well-handled. The comment explaining that the hover border isn't asserted under the synthetic-event runner (and was instead verified with real Playwright page.hover) is the right call — happy-dom/synthetic events don't engage CSS :hover. Good that the aria-pressed / fill behavior is still asserted in both unit and story play functions.

No blocking issues — the fix is correct, the abstraction reduces duplication, and tests/coverage are maintained. 👍
· fix/1460-filter-toggle-hover-border

@cliffhall

Copy link
Copy Markdown
Member Author

Thanks for the thorough review! All four are non-blocking; my take on each:

  1. Active + hover both lit — Keeping current behavior. An active button also "will change" (to off) when clicked, so the hover border is a correct "clicking will change this" cue there too — not just for inactive buttons. Universal hover feedback also keeps every toggle discoverably interactive. .filter-toggle:not([aria-pressed="true"]):hover would remove the affordance from active buttons, which I think is slightly worse for discoverability. Reasonable either way, as you noted.
  2. color: string free-form — Leaving as string. Mantine color props are inherently free-form strings (named token / var(--…) / etc.), and the sibling element AnnotationBadge types its color map values as string too. A union would be over-constrained and inconsistent with the codebase; callers already pass trusted tokens.
  3. NetworkControls clear-button test — Correct, it's a coverage backfill for the lines lost when the file shrank (the per-file 90% gate would otherwise fail), not a toggle test. Intentional.
  4. Storybook hover caveat — Agreed; the synthetic-event runner can't engage real CSS :hover, so the hover border is Playwright-verified and documented, while aria-pressed/fill stay asserted in unit + story play.

No code changes from this round since the items are all taste/observation. Re-requesting a review to confirm a clean pass.

@cliffhall

Copy link
Copy Markdown
Member Author

@claude review

@claude

claude Bot commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @cliffhall's task in 47s —— View job


Re-review: filter toggle hover as border, not background (#1460)

  • Read the updated diff and all changed files
  • Confirm the four prior observations are resolved/justified
  • Re-check correctness, conventions, and tests

Clean pass — confirmed. ✅ Nothing changed since the last round (as you noted, the four items were all taste/observation calls), and your dispositions are all reasonable:

  1. Active + hover both lit — agreed; an active button does "will change (to off)" on click, so the hover border is a correct affordance there too. Keeping universal hover feedback is the better discoverability tradeoff.
  2. color: string — consistent with AnnotationBadge's string-typed color map and Mantine's inherently free-form color props. A union would be over-constrained. Fine.
  3. NetworkControls clear-button test — understood as an intentional coverage backfill for the lines lost when the file shrank, not a toggle test.
  4. Storybook hover caveat — correct; synthetic events can't engage real CSS :hover, so the border is Playwright-verified while aria-pressed/fill stay asserted in unit + story play.

Re-verification of the diff

  • Extraction is clean and complete. All three consumers (LogControls, NetworkControls, MessageDirectionFilter) now route through FilterToggleButton, dropping the duplicated UnstyledButton + inline bg={active ? … : undefined} and their now-unused Text/UnstyledButton imports. The MessageDirectionFilter doc comment was updated to match (listItem toggle → FilterToggleButton) — nice attention to detail.
  • CSS is correct. .filter-toggle:hover (border-color) and .filter-toggle[aria-pressed="true"] (background-color) set disjoint properties at equal specificity, so they compose. The reserved 1px solid transparent border + border-box prevents layout shift, and the inline comment explaining why the border can't be an inline style (would outrank :hover) is exactly the trap a future maintainer would fall into.
  • Behavior preserved. onToggle(!active) reproduces the old onToggleLevel/Direction/Category(x, !active) semantics; callers adapt with (visible) => onToggle…(x, visible). Adding aria-pressed to the Logging toggles is a real a11y improvement and gives the unit tests a stable handle.
  • Tests cover both directions (toggle-on → true, toggle-off → false), plus aria-pressed reflection in both states, and the Inactive story correctly asserts the resolved transparent → rgba(0, 0, 0, 0) for both border and background.

No blocking issues, no new concerns — convention-compliant (theme variant + App.css pseudo-selectors only, Text.withProps subcomponent, no inline styles, no raw hex). Good to merge. 👍
· fix/1460-filter-toggle-hover-border

@cliffhall

Copy link
Copy Markdown
Member Author

Thanks for the clean re-review and the 👍 — all four items confirmed as reasonable dispositions with no new concerns. Ready to merge whenever.

@cliffhall
cliffhall merged commit d90cc4c into v2/main Jun 13, 2026
1 check passed
@cliffhall
cliffhall deleted the fix/1460-filter-toggle-hover-border branch June 13, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter toggle buttons (Logging / History / Network): toggling off looks like a no-op because hover background == active background

1 participant