list: Select first item on search. (#798)
This commit is contained in:
parent
5b508d7219
commit
034e465d28
2 changed files with 7 additions and 2 deletions
|
|
@ -170,7 +170,6 @@ impl ListDelegate for CompanyListDelegate {
|
||||||
.filter(|company| company.name.to_lowercase().contains(&query.to_lowercase()))
|
.filter(|company| company.name.to_lowercase().contains(&query.to_lowercase()))
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Task::ready(())
|
Task::ready(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,7 +276,7 @@ impl ListStory {
|
||||||
let delegate = CompanyListDelegate {
|
let delegate = CompanyListDelegate {
|
||||||
matched_companies: companies.clone(),
|
matched_companies: companies.clone(),
|
||||||
companies,
|
companies,
|
||||||
selected_index: None,
|
selected_index: Some(0),
|
||||||
confirmed_index: None,
|
confirmed_index: None,
|
||||||
query: "".to_string(),
|
query: "".to_string(),
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|
|
||||||
|
|
@ -339,6 +339,12 @@ where
|
||||||
self.set_querying(true, window, cx);
|
self.set_querying(true, window, cx);
|
||||||
let search = self.delegate.perform_search(&text, window, cx);
|
let search = self.delegate.perform_search(&text, window, cx);
|
||||||
|
|
||||||
|
if self.delegate.items_count(cx) > 0 {
|
||||||
|
self.set_selected_index(Some(0), window, cx);
|
||||||
|
} else {
|
||||||
|
self.set_selected_index(None, window, cx);
|
||||||
|
}
|
||||||
|
|
||||||
self._search_task = cx.spawn_in(window, async move |this, window| {
|
self._search_task = cx.spawn_in(window, async move |this, window| {
|
||||||
search.await;
|
search.await;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue