Skip to content

Combobox: Filter resets on blur → reopening ignores previous input #1164

@patorelovsky

Description

@patorelovsky

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:

  1. Type a non-matching string, e.g. asdf.
  2. Observe "No results".
  3. Click outside to blur.
  4. Click the toggle arrow to reopen.
  5. 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 = false on blur in ComboboxImpl, so the previous filter remains active.
  • Option B: Expose a searchTerm prop (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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions