Skip to content

fix(search): add backdrop overlay to autocomplete dropdown (#982)#986

Merged
ericsocrat merged 1 commit intomainfrom
fix/982-autocomplete-backdrop
Mar 19, 2026
Merged

fix(search): add backdrop overlay to autocomplete dropdown (#982)#986
ericsocrat merged 1 commit intomainfrom
fix/982-autocomplete-backdrop

Conversation

@ericsocrat
Copy link
Owner

Summary

Adds a translucent backdrop overlay behind the autocomplete dropdown on the search page. When suggestions appear, a �g-black/20 overlay dims the background, providing clear visual focus on the dropdown content.

Changes

  • SearchAutocomplete.tsx: Wrapped return in fragment, added ixed inset-0 z-40 backdrop with �ackdropIn fade animation, onClick={onClose} click-to-dismiss, �ria-hidden=true`n- SearchAutocomplete.test.tsx: 3 new tests — backdrop renders when visible, absent when hidden, click-to-dismiss calls onClose

Design Decisions

  • Backdrop at z-40, dropdown at z-50 — dropdown stays above overlay
  • �g-black/20 (lighter than modal backdrops) — dims without blocking
  • Input retains keyboard focus under overlay — typing continues seamlessly
  • Existing mousedown click-outside listener preserved as defensive fallback
  • Reuses existing @Keyframes backdropIn from globals.css

Verification

  • 32/32 SearchAutocomplete tests pass (29 existing + 3 new)
  • TypeScript: 0 errors

Closes #982

Copilot AI review requested due to automatic review settings March 19, 2026 22:24
@vercel
Copy link

vercel bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tryvit Ready Ready Preview, Comment Mar 19, 2026 10:26pm

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@github-actions
Copy link

📸 PR Screenshots

Captured 2 screenshots (1 mobile, 1 desktop) for 1 changed page(s):

  • search

📥 Download screenshots from workflow artifacts.

Captured by PR Screenshots workflow • 2026-03-19

@github-actions
Copy link

Bundle Size Report

Metric Value
Main baseline 0 KB
This PR 0 KB
Delta +0 KB (+0%)
JS chunks 0
Hard limit 4000 KB

✅ Bundle size is within acceptable limits.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dimming backdrop behind the search autocomplete dropdown to improve visual focus and provide a click-to-dismiss target on the search page.

Changes:

  • Add a full-viewport translucent backdrop element behind the autocomplete dropdown.
  • Wire backdrop clicks to onClose and animate it with the existing backdropIn keyframes.
  • Add tests verifying backdrop render/absence and click-to-dismiss behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
frontend/src/components/search/SearchAutocomplete.tsx Introduces a fixed-position backdrop overlay and wraps dropdown rendering in a fragment.
frontend/src/components/search/SearchAutocomplete.test.tsx Adds unit tests covering backdrop rendering and dismiss interaction.

Comment on lines +297 to +302
<div
className="fixed inset-0 z-40 bg-black/20 animate-[backdropIn_150ms_var(--ease-standard)]"
onClick={onClose}
aria-hidden="true"
data-testid="autocomplete-backdrop"
/>
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixed inset-0 backdrop will sit above the search input/clear button (which don’t have a higher z-index) and will intercept clicks there, immediately dismissing the dropdown and preventing users from placing the caret / clicking the clear button while suggestions are open. If the intent is to dim only the page content behind the dropdown (not the input), consider scoping the backdrop to start below the input (e.g., top offset) or ensuring the input wrapper is stacked above the backdrop (higher z-index) so it remains interactive.

Copilot uses AI. Check for mistakes.
{/* Backdrop overlay — dims content behind the dropdown */}
<div
className="fixed inset-0 z-40 bg-black/20 animate-[backdropIn_150ms_var(--ease-standard)]"
onClick={onClose}
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clicking the backdrop will currently trigger onClose via two paths: (1) the existing document-level mousedown outside-click handler (because the backdrop is not contained in containerRef), and (2) this backdrop’s onClick. In real usage this is often masked by unmounting on mousedown, but it can still lead to duplicate onClose calls (and makes tests less precise). Suggest either removing/adjusting the document mousedown listener when the backdrop is present, or handling dismissal on the backdrop’s onMouseDown with stopPropagation() and dropping the onClick handler.

Suggested change
onClick={onClose}
onMouseDown={(event) => {
event.stopPropagation();
onClose();
}}

Copilot uses AI. Check for mistakes.
);
const backdrop = screen.getByTestId("autocomplete-backdrop");
fireEvent.click(backdrop);
expect(onClose).toHaveBeenCalled();
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test only asserts that onClose was called, but with the current implementation a backdrop click can invoke onClose twice (document mousedown outside-click handler + backdrop onClick) when onClose doesn’t immediately unmount the component (as in this test). Strengthen this assertion to toHaveBeenCalledTimes(1) (and/or adjust the interaction to match the chosen dismissal event) so the test catches duplicate-close regressions.

Suggested change
expect(onClose).toHaveBeenCalled();
expect(onClose).toHaveBeenCalledTimes(1);

Copilot uses AI. Check for mistakes.
@ericsocrat ericsocrat merged commit 5315a74 into main Mar 19, 2026
22 checks passed
@ericsocrat ericsocrat deleted the fix/982-autocomplete-backdrop branch March 19, 2026 22:30
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.

fix(search): add backdrop overlay to autocomplete dropdown

2 participants