Skip to content

select: Clear the search query when the menu closes - #3050

Open
Muhammad-Owais-Warsi wants to merge 1 commit into
longbridge:mainfrom
Muhammad-Owais-Warsi:fix/select-clear-query-3047
Open

select: Clear the search query when the menu closes#3050
Muhammad-Owais-Warsi wants to merge 1 commit into
longbridge:mainfrom
Muhammad-Owais-Warsi:fix/select-clear-query-3047

Conversation

@Muhammad-Owais-Warsi

Copy link
Copy Markdown
Contributor

Closes #3047

Description

A searchable Select kept its filter query after the menu closed, so the next open showed the old query and a filtered list. clear_query had one caller, set_selected_value.

Confirm now clears the query after committing and re-resolves the confirmed value via position(), so the cursor and mark land on the full-list row (a filtered index would point at the wrong item). Cancel clears before restoring the cursor to the committed index. A new clear_query_and_restore_cursor helper covers every other close: trigger escape (click-out), on_blur, trigger-toggle close, and base on_open_change. Confirm/cancel clear through the held list_state directly to avoid re-entering the ListState lock that defer_in holds.

Screenshot

N/A

Break Changes

None

How to Test

Automated (mirrors the issue's repro: Dutch/English/French/Hungarian, type hun, close, reopen and navigate):

cargo test -p gpui-kit --features="test-support component" --test controls searchable_select

Both tests fail without the fix with the issue's exact signature (left: Hungarian, right: French) and pass with it. Also ran: full --test controls suite (6/6 pass), cargo test -p gpui-component select (all pass), cargo fmt --check (clean). Note: cargo clippy reports a pre-existing nonminimal_bool lint in crates/base/src/calendar.rs, untouched by this change.

Manual: open a .searchable(true) select, type part of an item name, press Enter (or Escape), reopen — the search field is empty and all items show with the mark on the current item.

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific)

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.

Searchable Select keeps the search query after the menu closes

1 participant