From 3d0adb1d3320f72b6a9b43903e5ed80737f646ac Mon Sep 17 00:00:00 2001 From: HalavicH Date: Tue, 7 Apr 2026 11:39:32 +0200 Subject: [PATCH] fix: Update the scrollbar selection in different render mode --- crates/ui/src/components/data_table.rs | 29 +++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/crates/ui/src/components/data_table.rs b/crates/ui/src/components/data_table.rs index a6d21191ea021695a4366f62a765ceef9e948f46..bc01781bca6f71ea72ecad346c1e574c9d4f7dd1 100644 --- a/crates/ui/src/components/data_table.rs +++ b/crates/ui/src/components/data_table.rs @@ -835,6 +835,11 @@ impl RenderOnce for Table { let table_width = self.column_width_config.table_width(window, cx); let horizontal_sizing = self.column_width_config.list_horizontal_sizing(window, cx); let no_rows_rendered = self.rows.is_empty(); + let variable_list_state = if let TableContents::VariableRowHeightList(data) = &self.rows { + Some(data.list_state.clone()) + } else { + None + }; // Extract redistributable entity for drag/drop/prepaint handlers let redistributable_entity = @@ -980,13 +985,23 @@ impl RenderOnce for Table { .custom_scrollbar .clone() .unwrap_or_else(|| Scrollbars::new(ScrollAxes::Both)); - content - .custom_scrollbars( - scrollbars.tracked_scroll_handle(&state.read(cx).scroll_handle), - window, - cx, - ) - .into_any_element() + if let Some(list_state) = variable_list_state { + content + .custom_scrollbars( + scrollbars.tracked_scroll_handle(&list_state), + window, + cx, + ) + .into_any_element() + } else { + content + .custom_scrollbars( + scrollbars.tracked_scroll_handle(&state.read(cx).scroll_handle), + window, + cx, + ) + .into_any_element() + } } else { content.into_any_element() }