-
Notifications
You must be signed in to change notification settings - Fork 384
Description
When a user types something that doesn’t match existing options, the combobox shows "No results". If they close it via the toggle (arrow), then reopen, the filtered state remains correctly. However, if they click outside (triggering onBlur) and then reopen, the filtering is lost and all options are shown again. This is because shouldFilter.current is reset on blur, and useFilteredData ignores previous searchTerm.
Steps to reproduce:
- Type a non-matching string, e.g.
asdf. - Observe "No results".
- Click outside to blur.
- Click the toggle arrow to reopen.
- The full options list appears, even though the input still contains
asdf.
Expected behavior:
After blur, reopening should preserve the filtered state (still show no results) if the input remains unchanged.
Possible fixes:
- Option A: Don’t reset
shouldFilter.current = falseon blur inComboboxImpl, so the previous filter remains active. - Option B: Expose a
searchTermprop (controlled) and allow consumers to maintain filter state across blur/open cycles. - Option C: Document the current behavior as intentional (but this seems unlikely).
Context from source:
useFilteredData(...) uses searchTerm, but since shouldFilter.current is set to false in Combobox's internal didHandle(focused), the Combobox passes '' as searchTerm after blur — so reopening resets the filter.
Version: latest (react-widgets v5.8.6)