Skip to content

searchable_list: Store selection by item value - #2653

Open
suxiaoshao wants to merge 7 commits into
longbridge:mainfrom
suxiaoshao:codex/2652-combobox-hidden-selection
Open

searchable_list: Store selection by item value#2653
suxiaoshao wants to merge 7 commits into
longbridge:mainfrom
suxiaoshao:codex/2652-combobox-hidden-selection

Conversation

@suxiaoshao

@suxiaoshao suxiaoshao commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #2652

Summary

  • store committed searchable-list selections as items and compare identity by Value
  • resolve hidden values through item_by_value; SearchableVec searches its complete source
  • keep IndexPath only for current visible cursor, click, and change positions
  • update Combobox, Select, stories, tests, and bilingual docs

IndexPath identifies a row in the current filtered view, not an option. Filtering can hide an item or make the same path refer to another item, while selection semantics already use Value.

Breaking Changes

  • Selection accessors and custom triggers now receive items only.
- &[(IndexPath, D::Item)]
+ &[D::Item]
  • Delegate selection hooks now receive item-only selections.
- current_selection: &[(IndexPath, Self::Item)]
+ current_selection: &[Self::Item]

- selection: &mut Vec<(IndexPath, Self::Item)>
+ selection: &mut Vec<Self::Item>

- final_selection: &[(IndexPath, Self::Item)]
+ final_selection: &[Self::Item]
  • SearchableListState::remove_selected_index resolves the current visible item and now requires the app context.
- state.remove_selected_index(index)
+ state.remove_selected_index(index, cx)

Custom delegates that need to resolve filtered-out values should override item_by_value.

Validation

  • cargo test -p gpui-component test_select_hidden_value_notifies_trigger
  • cargo check -p gpui-component --tests
  • cargo clippy -p gpui-component --all-targets -- --deny warnings
  • rustfmt --edition 2024 --check crates/ui/src/select.rs
  • git diff --check

@suxiaoshao

Copy link
Copy Markdown
Contributor Author

@codex review

@suxiaoshao
suxiaoshao marked this pull request as ready for review August 5, 2026 11:57
@suxiaoshao

Copy link
Copy Markdown
Contributor Author

@codex review

@suxiaoshao
suxiaoshao marked this pull request as draft August 5, 2026 12:28
@suxiaoshao
suxiaoshao marked this pull request as ready for review August 6, 2026 01:40
@suxiaoshao
suxiaoshao marked this pull request as draft August 8, 2026 04:00
@suxiaoshao
suxiaoshao marked this pull request as ready for review August 8, 2026 04:38
…-hidden-selection

# Conflicts:
#	crates/ui/src/select.rs
…-hidden-selection

# Conflicts:
#	crates/story/src/stories/combobox_story.rs
…-hidden-selection

# Conflicts:
#	crates/story/src/stories/combobox_story.rs
#	crates/ui/src/combobox.rs
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.

Combobox: set_selected_values drops hidden selections while search is active

1 participant