Skip to content

fix(ui): clicking filtered Combobox entries fails to trigger selection#15788

Merged
PatrikKozak merged 3 commits into
payloadcms:mainfrom
silmin:fix/combobox-search-selection
Mar 11, 2026
Merged

fix(ui): clicking filtered Combobox entries fails to trigger selection#15788
PatrikKozak merged 3 commits into
payloadcms:mainfrom
silmin:fix/combobox-search-selection

Conversation

@silmin
Copy link
Copy Markdown
Contributor

@silmin silmin commented Feb 27, 2026

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.

image

Why?

The Popup's handleActionableClick listener detects the [role="menuitem"] click and closes the popup, which calls setSearchValue('') via onToggleClose.
This rebuilds the entry list, removing the clicked DOM node before React's synthetic onClick can fire.

How?

The fix adds data-popup-prevent-close to Combobox entry divs.
Popup already checks for this attribute in handleActionableClick (Popup/index.tsx L323-324) and skips auto-closing, letting the Combobox's own handleClick handle both selection and closing.

One-line change in packages/ui/src/elements/Combobox/index.tsx.

@silmin silmin changed the title fix(ui): prevent Combobox search-filtered entries from losing click events fix(ui): prevent Combobox search-filtered entries from losing click events Feb 27, 2026
@silmin
Copy link
Copy Markdown
Contributor Author

silmin commented Feb 28, 2026

@jacobsfletch @AlessioGr @JarrodMFlesch
Hi wonderful maintainers,

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!

@PatrikKozak PatrikKozak self-assigned this Mar 10, 2026
@PatrikKozak PatrikKozak self-requested a review March 10, 2026 23:17
@PatrikKozak
Copy link
Copy Markdown
Contributor

Hey @silmin

Changes here look good! I went ahead and added an e2e test so there isn't regression in the future.

Thank you for the contribution! Will merge once CI passes

@PatrikKozak PatrikKozak changed the title fix(ui): prevent Combobox search-filtered entries from losing click events fix(ui): clicking filtered Combobox entries fails to trigger selection Mar 10, 2026
@PatrikKozak PatrikKozak enabled auto-merge (squash) March 10, 2026 23:22
@PatrikKozak PatrikKozak merged commit de3e5ae into payloadcms:main Mar 11, 2026
293 of 302 checks passed
@silmin
Copy link
Copy Markdown
Contributor Author

silmin commented Mar 12, 2026

Hey @PatrikKozak
Thank you so much! I'm happy to hear that!

@github-actions
Copy link
Copy Markdown
Contributor

🚀 This is included in version v3.79.1

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.

2 participants