diff --git a/crates/story/src/list_story.rs b/crates/story/src/list_story.rs index ae5e1aa9..aee26bed 100644 --- a/crates/story/src/list_story.rs +++ b/crates/story/src/list_story.rs @@ -270,7 +270,12 @@ impl ListDelegate for CompanyListDelegate { ) } - fn render_item(&mut self, ix: IndexPath, _: &mut Window, _: &mut Context>) -> Option { + fn render_item( + &mut self, + ix: IndexPath, + _: &mut Window, + _: &mut Context>, + ) -> Option { let selected = Some(ix) == self.selected_index || Some(ix) == self.confirmed_index; if let Some(company) = self.matched_companies[ix.section].get(ix.row) { return Some(CompanyListItem::new(ix, company.clone(), selected)); diff --git a/crates/ui/src/list/cache.rs b/crates/ui/src/list/cache.rs index f1a92ed2..840c37bb 100644 --- a/crates/ui/src/list/cache.rs +++ b/crates/ui/src/list/cache.rs @@ -147,10 +147,6 @@ impl RowsCache { path } - pub(crate) fn measured_size(&self) -> MeasuredEntrySize { - self.measured_size - } - pub(crate) fn prepare_if_needed( &mut self, sections_count: usize, @@ -207,7 +203,7 @@ impl RowsCache { mod tests { use std::rc::Rc; - use crate::{list::cache::RowsCache, IndexPath}; + use crate::{IndexPath, list::cache::RowsCache}; #[test] fn test_prev_next() { diff --git a/crates/ui/src/list/list.rs b/crates/ui/src/list/list.rs index 666384fc..75eb74e1 100644 --- a/crates/ui/src/list/list.rs +++ b/crates/ui/src/list/list.rs @@ -66,6 +66,8 @@ impl Default for ListOptions { } /// The state for List. +/// +/// List required all items has the same height. pub struct ListState { pub(crate) focus_handle: FocusHandle, pub(crate) query_input: Entity, @@ -447,6 +449,7 @@ where .id(id) .w_full() .relative() + .overflow_hidden() .children(self.delegate.render_item(ix, window, cx).map(|item| { item.selected(selected) .secondary_selected(mouse_right_clicked) @@ -483,13 +486,11 @@ where let rows_cache = self.rows_cache.clone(); let scrollbar_visible = self.options.scrollbar_visible; let scroll_handle = self.scroll_handle.clone(); - let measured_size = rows_cache.measured_size(); v_flex() .flex_grow() .relative() - .h_full() - .min_w(measured_size.item_size.width) + .size_full() .when_some(self.options.max_height, |this, h| this.max_h(h)) .overflow_hidden() .when(items_count == 0, |this| {