Repository navigation
✨ feat(combobox): add opt-in @onClose callback - #216
Open
dmcnamara-eng wants to merge 1 commit into
Open
dmcnamara-eng wants to merge 1 commit into
dmcnamara-eng wants to merge 1 commit into
Conversation
Called once whenever an open combobox closes: click outside, Tab, Escape, selecting an option or the button toggle. Lets consumers react to dismissal (e.g. commit a typed query as free text) without wiring their own focusout handler. Mirrors Headless UI React v2's `onClose`. @onchange is unchanged and is still only called with option values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dmcnamara-eng
marked this pull request as ready for review
November 12, 2026 10:49
dmcnamara-eng
requested review from
GavinJoyce,
NullVoxPopuli,
achambers,
alexlafroscia and
mansona
November 12, 2026 10:50
This branch has not been deployed
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
Adds an optional
@onCloseargument to<Combobox>. It's called once, with no arguments, whenever an open combobox closes:TabEscapeIt isn't called on render, or when the combobox was already closed.
Why
Some consumers accept free text: they filter options as the user types and keep whatever was typed even if no option is picked. Right now there's no way to tell when the combobox has been dismissed. On click outside,
handleClickOutsideresets the input to the selected value, so the typed query is lost. Consumers end up adding their ownfocusouthandler on a wrapper element. We have two of these in one app.This mirrors
onCloseon Headless UI React v2'sCombobox.Why not call
@onChangeon blur?We considered calling
@onChangewith the typed text when the combobox closes, and decided against it:@onChangereceives option values, which are often objects. Passing a raw string there would break that contract for every existing consumer.handleClickOutsiderestores_originalValue). It also matches Headless UI React, where free text is offered as an option.@onCloseis opt-in and doesn't change behaviour for anyone who doesn't pass it.Implementation
The hook is in the
isOpensetter, which every close path already goes through. It fires only on an open → closed transition, after state has been updated.Tests
There's a new
Combobox @onClosemodule incombobox-test.jswith 7 tests:@onChangeThe full
<Combobox>suite passes locally: 100 pass, 0 fail, plus the existing skip/todo. With theonClosecall removed, the 5 positive tests fail.🤖 Generated with Claude Code