-
Notifications
You must be signed in to change notification settings - Fork 0
fix(search): add backdrop overlay to autocomplete dropdown (#982) #986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -292,13 +292,21 @@ export function SearchAutocomplete({ | |||||||||||
| : t(dropdownLabelKey); | ||||||||||||
|
|
||||||||||||
| return ( | ||||||||||||
| <div | ||||||||||||
| ref={containerRef} | ||||||||||||
| id="search-autocomplete-listbox" | ||||||||||||
| role="listbox" | ||||||||||||
| aria-label={dropdownLabel} | ||||||||||||
| className="absolute left-0 right-0 top-full z-50 mt-1 max-h-80 overflow-y-auto rounded-xl border bg-surface shadow-lg" | ||||||||||||
| > | ||||||||||||
| <> | ||||||||||||
| {/* 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} | ||||||||||||
|
||||||||||||
| onClick={onClose} | |
| onMouseDown={(event) => { | |
| event.stopPropagation(); | |
| onClose(); | |
| }} |
Copilot
AI
Mar 19, 2026
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
onClosewas called, but with the current implementation a backdrop click can invokeonClosetwice (documentmousedownoutside-click handler + backdroponClick) whenonClosedoesn’t immediately unmount the component (as in this test). Strengthen this assertion totoHaveBeenCalledTimes(1)(and/or adjust the interaction to match the chosen dismissal event) so the test catches duplicate-close regressions.