Skip to content

fix(site): readable active-state for Algolia DocSearch hits#3814

Merged
jasonbahl merged 1 commit into
wp-graphql:mainfrom
jasonbahl:fix/algolia-search-styles
May 9, 2026
Merged

fix(site): readable active-state for Algolia DocSearch hits#3814
jasonbahl merged 1 commit into
wp-graphql:mainfrom
jasonbahl:fix/algolia-search-styles

Conversation

@jasonbahl
Copy link
Copy Markdown
Collaborator

Summary

Fixes contrast for the active/hovered hit in the Algolia DocSearch modal. In dark mode, Page hits and recent-history hits were rendering with near-invisible text — navy-950 title on a navy-800 muted
background.

Why

The previous active-state rules only worked for .DocSearch-Hit--Result hits. They:

  • Set the inner .DocSearch-Hit--Result div to orange background + navy-950 text (correct for an orange surface), and
  • Set every .DocSearch-Hit-title under [aria-selected='true'] to navy-950 (--primary-foreground)

For Page and recent-history hits there's no inner .DocSearch-Hit--Result wrapper, so the orange background never rendered — but the title-color flip still ran. That left navy-950 text sitting on the
muted-bg (also dark navy), so the entry was unreadable as soon as you arrowed onto it.

What changed

src/styles/docsearch.css — replace the mixed treatment with one consistent active state that works for every hit type:

  • Active background: hsl(var(--accent)) (subtle panel, swaps per theme)
  • Active text: kept at hsl(var(--foreground)) — no longer flipped
  • Visual cue for the active row: a 3px orange (--primary) inset box-shadow on the left edge

Applied uniformly to both .DocSearch-Hit > a (Page / RecentItem hits) and .DocSearch-Hit--Result (Result hits). Also updated the active state of .DocSearch-Hit-icon (orange stroke + border instead of a
white SVG meant for an orange surface) and .DocSearch-Hit-action path stroke.

The previous active-state rules broke for Page hits and recent-history
hits in dark mode. The orange treatment only ever applied to
.DocSearch-Hit--Result divs, but the title-color flip
(--primary-foreground = navy-950) ran for ALL aria-selected hits,
regardless of whether their <a> background actually became orange.
Result: navy-950 text on navy-800 muted background → invisible.

Switch to a uniform active treatment that works for every hit type:
- Background: hsl(var(--accent)) (subtle accent panel)
- Text: hsl(var(--foreground)) (kept readable, not flipped)
- Visual cue: 3px primary-orange inset shadow on the left edge

Same rules applied on .DocSearch-Hit > a (Page / RecentItem hits) and
.DocSearch-Hit--Result (Result hits), so contrast is consistent
regardless of whether the hit has the inner --Result wrapper.

Also drop white SVG fill on the active hit-icon (intended to read on
orange) and switch to primary-coloured stroke + border, matching the
left accent bar. Same fix on the action-arrow stroke.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 9, 2026

@jasonbahl is attempting to deploy a commit to the WPGraphql Team on Vercel.

A member of the Team first needs to authorize it.

@jasonbahl jasonbahl merged commit bb4d25a into wp-graphql:main May 9, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant