[combobox] Fix cancellation when preserving the filter after selection - #5362
[combobox] Fix cancellation when preserving the filter after selection#5362atomiks wants to merge 15 commits into
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,310.36 ms +35.29 ms(+2.8%) | Renders: 76 (+0) | Paint: 2,072.80 ms +70.30 ms(+3.5%)
11 tests within noise — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
cb7e9f4 to
7e35596
Compare
2cce734 to
477303e
Compare
|
@claude review low |
PR reviewThe two cancellation fixes in Bugs (1)1. 🟠 Reopening during the exit animation now filters a single-select list down to just the selected itemLocation: if (nextOpen && closeQuery !== null) {
const isInputChange = eventDetails.reason === REASONS.inputChange;
const clearsPendingInput =
!isInputChange && inputInsidePopup && !inline && inputValue !== '';
if (!isInputChange && (clearsPendingInput || inputValue === '')) {
setQueryChangedAfterOpen(false);
}
setCloseQuery(null);
...The outer guard lost its For Before this PR the block was skipped entirely for outside-popup inputs, so Failure scenario: Single-select combobox with the input outside the popup and an exit animation. Type Fix: Also reset VerdictApprove after nits - the cancellation fixes are correct; the only issue is a narrow interrupted-exit-animation regression in single-select filtering introduced by widening the reopen guard. 🤖 Review generated with Claude Code · |
Fixes two cancellation bugs that could leave stale filter text after selecting an item in
multiplemode and later reopening the popup:input-clearwas recorded as completed before the cancellation check. This suppressed the cleanup clear when the popup unmounted, so the next open could remain filtered by the previous query.The runtime changes ensure that only committed clears are recorded and that cleanup clears carry no gesture event.
We have two options to support keeping filter text in
multiplemode in v1:keepFilterTextprop ([combobox] AddkeepFilterTextprop for repeated selections #4360), which is conditional onmultiple(not great)isItemPresseventDetailsproperty foronInputChange(input-clearblocks this in v1)For No. 2, to keep the typed filter after selection, cancel the flagged clear in
onInputValueChange(input inside the popup) or theitem-pressclose inonOpenChange(input outside).Why
input-clearshould change in v2input-clearis the only effect-based reason in an otherwise cause-based union (item-press,escape-key,clear-press, …). The effect is redundant becauseonInputValueChangealready receives the new value, while the cause is what consumers actually need to discriminate on.isItemPressbridges this additively since v1 reasons are frozen (#4348).In v2, we should replace
input-clearwith cause-based reasons and dropisItemPress.