Reveal the selected item when cycling a picker's selection (#12950)
Release Notes: - Fixed a bug where the selected tab was not always shown when cycling between tabs with `ctrl-tab`.
This commit is contained in:
parent
0ac9af94e0
commit
76b0120665
5 changed files with 61 additions and 1 deletions
|
@ -12,6 +12,9 @@ workspace = true
|
|||
path = "src/picker.rs"
|
||||
doctest = false
|
||||
|
||||
[features]
|
||||
test-support = []
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
editor.workspace = true
|
||||
|
|
|
@ -310,7 +310,7 @@ impl<D: PickerDelegate> Picker<D> {
|
|||
let count = self.delegate.match_count();
|
||||
let index = self.delegate.selected_index();
|
||||
let new_index = if index + 1 == count { 0 } else { index + 1 };
|
||||
self.set_selected_index(new_index, false, cx);
|
||||
self.set_selected_index(new_index, true, cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
|
@ -538,6 +538,16 @@ impl<D: PickerDelegate> Picker<D> {
|
|||
.into_any_element(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub fn logical_scroll_top_index(&self) -> usize {
|
||||
match &self.element_container {
|
||||
ElementContainer::List(state) => state.logical_scroll_top().item_ix,
|
||||
ElementContainer::UniformList(scroll_handle) => {
|
||||
scroll_handle.logical_scroll_top_index()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: PickerDelegate> EventEmitter<DismissEvent> for Picker<D> {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue