From 82cff4e952758e1fabf32ced9ba6bba9a5c85a72 Mon Sep 17 00:00:00 2001 From: reya Date: Wed, 4 Mar 2026 09:56:22 +0700 Subject: [PATCH] fix scrollbar not show --- crates/chat_ui/src/lib.rs | 4 ++-- crates/coop/src/sidebar/mod.rs | 23 +++++++++++------------ crates/theme/src/lib.rs | 2 +- crates/ui/src/scroll/scrollable.rs | 8 +++++--- crates/ui/src/scroll/scrollbar.rs | 12 ++++++------ 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/crates/chat_ui/src/lib.rs b/crates/chat_ui/src/lib.rs index 37ef7dd..2ffaf8a 100644 --- a/crates/chat_ui/src/lib.rs +++ b/crates/chat_ui/src/lib.rs @@ -1308,9 +1308,9 @@ impl Render for ChatPanel { .on_action(cx.listener(Self::on_command)) .size_full() .child( - div() + v_flex() .flex_1() - .size_full() + .relative() .child( list( self.list_state.clone(), diff --git a/crates/coop/src/sidebar/mod.rs b/crates/coop/src/sidebar/mod.rs index a88da6c..bb435ef 100644 --- a/crates/coop/src/sidebar/mod.rs +++ b/crates/coop/src/sidebar/mod.rs @@ -8,14 +8,14 @@ use common::{DebouncedDelay, RenderedTimestamp}; use entry::RoomEntry; use gpui::prelude::FluentBuilder; use gpui::{ - div, uniform_list, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable, - IntoElement, ParentElement, Render, RetainAllImageCache, SharedString, Styled, Subscription, - Task, UniformListScrollHandle, Window, + App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable, IntoElement, + ParentElement, Render, RetainAllImageCache, SharedString, Styled, Subscription, Task, + UniformListScrollHandle, Window, div, uniform_list, }; use nostr_sdk::prelude::*; use person::PersonRegistry; -use smallvec::{smallvec, SmallVec}; -use state::{NostrRegistry, FIND_DELAY}; +use smallvec::{SmallVec, smallvec}; +use state::{FIND_DELAY, NostrRegistry}; use theme::{ActiveTheme, SIDEBAR_WIDTH, TABBAR_HEIGHT}; use ui::button::{Button, ButtonVariants}; use ui::dock_area::panel::{Panel, PanelEvent}; @@ -23,7 +23,7 @@ use ui::indicator::Indicator; use ui::input::{InputEvent, InputState, TextInput}; use ui::notification::Notification; use ui::scroll::Scrollbar; -use ui::{h_flex, v_flex, Icon, IconName, Selectable, Sizable, StyledExt, WindowExtension}; +use ui::{Icon, IconName, Selectable, Sizable, StyledExt, WindowExtension, h_flex, v_flex}; mod entry; @@ -585,7 +585,7 @@ impl Render for Sidebar { ) .when(!show_find_panel && !loading && total_rooms == 0, |this| { this.child( - div().px_2().w(SIDEBAR_WIDTH).child( + div().w(SIDEBAR_WIDTH).px_2().child( v_flex() .p_3() .h_24() @@ -613,11 +613,9 @@ impl Render for Sidebar { }) .child( v_flex() - .h_full() - .px_1p5() - .gap_1() + .size_full() .flex_1() - .overflow_y_hidden() + .gap_1() .when(show_find_panel, |this| { this.gap_3() .when_some(self.find_results.read(cx).as_ref(), |this, results| { @@ -688,7 +686,8 @@ impl Render for Sidebar { ) .track_scroll(&self.scroll_handle) .flex_1() - .h_full(), + .h_full() + .px_2(), ) .child(Scrollbar::vertical(&self.scroll_handle)) }), diff --git a/crates/theme/src/lib.rs b/crates/theme/src/lib.rs index 717280e..7cc65d8 100644 --- a/crates/theme/src/lib.rs +++ b/crates/theme/src/lib.rs @@ -1,7 +1,7 @@ use std::ops::{Deref, DerefMut}; use std::rc::Rc; -use gpui::{px, App, Global, Pixels, SharedString, Window}; +use gpui::{App, Global, Pixels, SharedString, Window, px}; mod colors; mod platform_kind; diff --git a/crates/ui/src/scroll/scrollable.rs b/crates/ui/src/scroll/scrollable.rs index 821694e..4333890 100644 --- a/crates/ui/src/scroll/scrollable.rs +++ b/crates/ui/src/scroll/scrollable.rs @@ -3,13 +3,13 @@ use std::rc::Rc; use gpui::prelude::FluentBuilder; use gpui::{ - div, App, Div, Element, ElementId, InteractiveElement, IntoElement, ParentElement, RenderOnce, - ScrollHandle, Stateful, StatefulInteractiveElement, StyleRefinement, Styled, Window, + App, Div, Element, ElementId, InteractiveElement, IntoElement, ParentElement, RenderOnce, + ScrollHandle, Stateful, StatefulInteractiveElement, StyleRefinement, Styled, Window, div, }; use super::{Scrollbar, ScrollbarAxis}; -use crate::scroll::ScrollbarHandle; use crate::StyledExt; +use crate::scroll::ScrollbarHandle; /// A trait for elements that can be made scrollable with scrollbars. pub trait ScrollableElement: InteractiveElement + Styled + ParentElement + Element { @@ -160,6 +160,7 @@ where } impl ScrollableElement for Div {} + impl ScrollableElement for Stateful where E: ParentElement + Styled + Element, @@ -195,6 +196,7 @@ fn render_scrollbar( // Do not render scrollbar when inspector is picking elements, // to allow us to pick the background elements. let is_inspector_picking = window.is_inspector_picking(cx); + if is_inspector_picking { return div(); } diff --git a/crates/ui/src/scroll/scrollbar.rs b/crates/ui/src/scroll/scrollbar.rs index e78a3b7..9145109 100644 --- a/crates/ui/src/scroll/scrollbar.rs +++ b/crates/ui/src/scroll/scrollbar.rs @@ -5,11 +5,11 @@ use std::rc::Rc; use std::time::{Duration, Instant}; use gpui::{ - fill, point, px, relative, size, App, Axis, BorderStyle, Bounds, ContentMask, Corner, - CursorStyle, Edges, Element, ElementId, GlobalElementId, Hitbox, HitboxBehavior, Hsla, - InspectorElementId, IntoElement, IsZero, LayoutId, ListState, MouseDownEvent, MouseMoveEvent, - MouseUpEvent, PaintQuad, Pixels, Point, Position, ScrollHandle, ScrollWheelEvent, Size, Style, - UniformListScrollHandle, Window, + App, Axis, BorderStyle, Bounds, ContentMask, Corner, CursorStyle, Edges, Element, ElementId, + GlobalElementId, Hitbox, HitboxBehavior, Hsla, InspectorElementId, IntoElement, IsZero, + LayoutId, ListState, MouseDownEvent, MouseMoveEvent, MouseUpEvent, PaintQuad, Pixels, Point, + Position, ScrollHandle, ScrollWheelEvent, Size, Style, UniformListScrollHandle, Window, fill, + point, px, relative, size, }; use theme::{ActiveTheme, ScrollbarMode}; @@ -407,7 +407,6 @@ impl Scrollbar { ScrollbarMode::Scrolling => (THUMB_WIDTH, THUMB_INSET, THUMB_RADIUS), _ => (THUMB_ACTIVE_WIDTH, THUMB_ACTIVE_INSET, THUMB_ACTIVE_RADIUS), }; - ( cx.theme().scrollbar_thumb_background, cx.theme().scrollbar_track_background, @@ -522,6 +521,7 @@ impl Element for Scrollbar { let mut states = vec![]; let mut has_both = self.axis.is_both(); + let scroll_size = self .scroll_size .unwrap_or(self.scroll_handle.content_size());