diff --git a/crates/story/src/table_story.rs b/crates/story/src/table_story.rs index fe8cd78a..a0d73e4b 100644 --- a/crates/story/src/table_story.rs +++ b/crates/story/src/table_story.rs @@ -283,13 +283,8 @@ impl TableDelegate for StockTableDelegate { } fn col_width(&self, col_ix: usize) -> Option { - if let Some(col) = self.columns.get(col_ix) { - Some( - match col.id.as_ref() { - _ => 120.0, - } - .into(), - ) + if let Some(_) = self.columns.get(col_ix) { + Some(120.0.into()) } else { None } diff --git a/crates/ui/src/table.rs b/crates/ui/src/table.rs index ce94ca21..bf46bf17 100644 --- a/crates/ui/src/table.rs +++ b/crates/ui/src/table.rs @@ -288,6 +288,11 @@ where cx.notify(); } + /// When we update columns or rows, we need to refresh the table. + pub fn refresh(&mut self, cx: &mut ViewContext) { + self.prepare_col_groups(cx); + } + fn prepare_col_groups(&mut self, cx: &mut ViewContext) { self.col_groups = (0..self.delegate.cols_count()) .map(|col_ix| ColGroup {