fix(ui): prevent Combobox search-filtered entries from losing click events#15788
Open
silmin wants to merge 1 commit intopayloadcms:mainfrom
Open
fix(ui): prevent Combobox search-filtered entries from losing click events#15788silmin wants to merge 1 commit intopayloadcms:mainfrom
silmin wants to merge 1 commit intopayloadcms:mainfrom
Conversation
Author
|
@jacobsfletch @AlessioGr @JarrodMFlesch Just a gentle ping on this PR. Has anyone had a chance to take a look? I am currently working around this issue in my local environment using pnpm patch, but I believe this fix would be very helpful for everyone else using the Combobox component. I would really appreciate it if you could review this when you have some time. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
When using the Combobox with search filtering (e.g. CodeBlock language selector), clicking a filtered entry closes the popup but doesn't trigger
onSelect. Without filtering, selection works correctly.Why?
The Popup's
handleActionableClicklistener detects the[role="menuitem"]click and closes the popup, which callssetSearchValue('')viaonToggleClose.This rebuilds the entry list, removing the clicked DOM node before React's synthetic
onClickcan fire.How?
The fix adds
data-popup-prevent-closeto Combobox entry divs.Popup already checks for this attribute in
handleActionableClick(Popup/index.tsx L323-324) and skips auto-closing, letting the Combobox's ownhandleClickhandle both selection and closing.One-line change in
packages/ui/src/elements/Combobox/index.tsx.