From 3601cb399b6fb548a9b0fed1a16dc6880691cb6e Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 24 Dec 2024 11:40:50 +0800 Subject: [PATCH] table: Use deferred to render scrollbar to avoid some element overflow it. (#513) --- crates/ui/src/table.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/crates/ui/src/table.rs b/crates/ui/src/table.rs index d93ad760..56ca3cbd 100644 --- a/crates/ui/src/table.rs +++ b/crates/ui/src/table.rs @@ -11,8 +11,8 @@ use crate::{ Icon, IconName, Sizable, Size, StyleSized as _, }; use gpui::{ - actions, canvas, div, prelude::FluentBuilder, px, uniform_list, AppContext, Axis, Bounds, Div, - DragMoveEvent, Edges, Entity, EntityId, EventEmitter, FocusHandle, FocusableView, + actions, canvas, deferred, div, prelude::FluentBuilder, px, uniform_list, AppContext, Axis, + Bounds, Div, DragMoveEvent, Edges, Entity, EntityId, EventEmitter, FocusHandle, FocusableView, InteractiveElement, IntoElement, KeyBinding, ListSizingBehavior, MouseButton, ParentElement, Pixels, Point, Render, ScrollHandle, ScrollStrategy, SharedString, Stateful, StatefulInteractiveElement as _, Styled, UniformListScrollHandle, ViewContext, @@ -1248,10 +1248,21 @@ where move |bounds, cx| view.update(cx, |r, _| r.bounds = bounds), |_, _, _| {}, )) - .child(self.render_horizontal_scrollbar(cx)) - .when(rows_count > 0, |this| { - this.children(self.render_scrollbar(cx)) - }) + .child( + // use deferred to render the scrollbar for + // avoid some custom element overflow the scrollbar. + deferred( + div() + .absolute() + .top_0() + .size_full() + .child(self.render_horizontal_scrollbar(cx)) + .when(rows_count > 0, |this| { + this.children(self.render_scrollbar(cx)) + }), + ) + .with_priority(0), + ) // Click out to cancel right clicked row .when(self.right_clicked_row.is_some(), |this| { this.on_mouse_down_out(cx.listener(|this, _, cx| {