Skip to content

Commit

Permalink
table: Use deferred to render scrollbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Dec 24, 2024
1 parent ea0954b commit 98b5c21
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions crates/ui/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use crate::{
theme::ActiveTheme,
v_flex,
virtual_list::virtual_list,
Icon, IconName, Sizable, Size, StyleSized as _,
Icon, IconName, Sizable, Size, StyleSized as _, StyledExt,

Check failure on line 11 in crates/ui/src/table.rs

View workflow job for this annotation

GitHub Actions / Test

unused import: `StyledExt`
};
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,
Expand Down Expand Up @@ -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 custome 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| {
Expand Down

0 comments on commit 98b5c21

Please sign in to comment.