From 0fdf7be40dd169facd8c4db6346e7855bf558342 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Wed, 17 Jul 2024 23:19:03 +0800 Subject: [PATCH] Fix table scrollbar display layer. --- crates/ui/src/input/input_otp.rs | 6 +++--- crates/ui/src/table.rs | 26 +++++++++++++++++--------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/crates/ui/src/input/input_otp.rs b/crates/ui/src/input/input_otp.rs index ed3f11ee..f59d6c80 100644 --- a/crates/ui/src/input/input_otp.rs +++ b/crates/ui/src/input/input_otp.rs @@ -1,10 +1,10 @@ use gpui::{ - div, prelude::FluentBuilder as _, AnyElement, Context, Div, FocusHandle, FocusableView, + div, prelude::FluentBuilder as _, AnyElement, Context, FocusHandle, FocusableView, InteractiveElement, IntoElement, KeyDownEvent, Model, MouseButton, MouseDownEvent, - ParentElement as _, Render, SharedString, Stateful, Styled as _, ViewContext, WindowContext, + ParentElement as _, Render, SharedString, Styled as _, ViewContext, WindowContext, }; -use crate::{h_flex, theme::ActiveTheme, v_flex, StyledExt}; +use crate::{h_flex, theme::ActiveTheme, v_flex}; use super::blink_cursor::BlinkCursor; diff --git a/crates/ui/src/table.rs b/crates/ui/src/table.rs index 8b57d41d..0db6ab93 100644 --- a/crates/ui/src/table.rs +++ b/crates/ui/src/table.rs @@ -7,8 +7,8 @@ use crate::{ v_flex, }; use gpui::{ - actions, deferred, div, prelude::FluentBuilder as _, px, uniform_list, AppContext, Div, - FocusHandle, FocusableView, InteractiveElement as _, IntoElement, KeyBinding, MouseButton, + actions, div, prelude::FluentBuilder as _, px, uniform_list, AppContext, Div, FocusHandle, + FocusableView, InteractiveElement as _, IntoElement, KeyBinding, MouseButton, ParentElement as _, Render, ScrollHandle, SharedString, StatefulInteractiveElement as _, Styled, UniformListScrollHandle, ViewContext, WindowContext, }; @@ -255,12 +255,20 @@ where let view = cx.view().clone(); let state = self.scrollbar_state.clone(); - Some(deferred(Scrollbar::uniform_scroll( - view, - state, - self.vertical_scroll_handle.clone(), - self.delegate.rows_count(), - ))) + Some( + div() + .absolute() + .top_0() + .left_0() + .right_0() + .bottom_0() + .child(Scrollbar::uniform_scroll( + view, + state, + self.vertical_scroll_handle.clone(), + self.delegate.rows_count(), + )), + ) } } @@ -408,8 +416,8 @@ where .border_1() .border_color(cx.theme().border) .bg(cx.theme().card) - .children(self.render_scrollbar(cx)) .child(inner_table) + .children(self.render_scrollbar(cx)) .child(ScrollableMask::new( cx.view().clone(), ScrollableAxis::Horizontal,