fix scrollbar not show
Some checks failed
Rust / build (ubuntu-latest, stable) (push) Failing after 1m54s
Rust / build (macos-latest, stable) (push) Has been cancelled
Rust / build (windows-latest, stable) (push) Has been cancelled

This commit is contained in:
2026-03-04 09:56:22 +07:00
parent b3eef2a048
commit 82cff4e952
5 changed files with 25 additions and 24 deletions

View File

@@ -1308,9 +1308,9 @@ impl Render for ChatPanel {
.on_action(cx.listener(Self::on_command)) .on_action(cx.listener(Self::on_command))
.size_full() .size_full()
.child( .child(
div() v_flex()
.flex_1() .flex_1()
.size_full() .relative()
.child( .child(
list( list(
self.list_state.clone(), self.list_state.clone(),

View File

@@ -8,14 +8,14 @@ use common::{DebouncedDelay, RenderedTimestamp};
use entry::RoomEntry; use entry::RoomEntry;
use gpui::prelude::FluentBuilder; use gpui::prelude::FluentBuilder;
use gpui::{ use gpui::{
div, uniform_list, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable, IntoElement,
IntoElement, ParentElement, Render, RetainAllImageCache, SharedString, Styled, Subscription, ParentElement, Render, RetainAllImageCache, SharedString, Styled, Subscription, Task,
Task, UniformListScrollHandle, Window, UniformListScrollHandle, Window, div, uniform_list,
}; };
use nostr_sdk::prelude::*; use nostr_sdk::prelude::*;
use person::PersonRegistry; use person::PersonRegistry;
use smallvec::{smallvec, SmallVec}; use smallvec::{SmallVec, smallvec};
use state::{NostrRegistry, FIND_DELAY}; use state::{FIND_DELAY, NostrRegistry};
use theme::{ActiveTheme, SIDEBAR_WIDTH, TABBAR_HEIGHT}; use theme::{ActiveTheme, SIDEBAR_WIDTH, TABBAR_HEIGHT};
use ui::button::{Button, ButtonVariants}; use ui::button::{Button, ButtonVariants};
use ui::dock_area::panel::{Panel, PanelEvent}; use ui::dock_area::panel::{Panel, PanelEvent};
@@ -23,7 +23,7 @@ use ui::indicator::Indicator;
use ui::input::{InputEvent, InputState, TextInput}; use ui::input::{InputEvent, InputState, TextInput};
use ui::notification::Notification; use ui::notification::Notification;
use ui::scroll::Scrollbar; 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; mod entry;
@@ -585,7 +585,7 @@ impl Render for Sidebar {
) )
.when(!show_find_panel && !loading && total_rooms == 0, |this| { .when(!show_find_panel && !loading && total_rooms == 0, |this| {
this.child( this.child(
div().px_2().w(SIDEBAR_WIDTH).child( div().w(SIDEBAR_WIDTH).px_2().child(
v_flex() v_flex()
.p_3() .p_3()
.h_24() .h_24()
@@ -613,11 +613,9 @@ impl Render for Sidebar {
}) })
.child( .child(
v_flex() v_flex()
.h_full() .size_full()
.px_1p5()
.gap_1()
.flex_1() .flex_1()
.overflow_y_hidden() .gap_1()
.when(show_find_panel, |this| { .when(show_find_panel, |this| {
this.gap_3() this.gap_3()
.when_some(self.find_results.read(cx).as_ref(), |this, results| { .when_some(self.find_results.read(cx).as_ref(), |this, results| {
@@ -688,7 +686,8 @@ impl Render for Sidebar {
) )
.track_scroll(&self.scroll_handle) .track_scroll(&self.scroll_handle)
.flex_1() .flex_1()
.h_full(), .h_full()
.px_2(),
) )
.child(Scrollbar::vertical(&self.scroll_handle)) .child(Scrollbar::vertical(&self.scroll_handle))
}), }),

View File

@@ -1,7 +1,7 @@
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::rc::Rc; use std::rc::Rc;
use gpui::{px, App, Global, Pixels, SharedString, Window}; use gpui::{App, Global, Pixels, SharedString, Window, px};
mod colors; mod colors;
mod platform_kind; mod platform_kind;

View File

@@ -3,13 +3,13 @@ use std::rc::Rc;
use gpui::prelude::FluentBuilder; use gpui::prelude::FluentBuilder;
use gpui::{ use gpui::{
div, App, Div, Element, ElementId, InteractiveElement, IntoElement, ParentElement, RenderOnce, App, Div, Element, ElementId, InteractiveElement, IntoElement, ParentElement, RenderOnce,
ScrollHandle, Stateful, StatefulInteractiveElement, StyleRefinement, Styled, Window, ScrollHandle, Stateful, StatefulInteractiveElement, StyleRefinement, Styled, Window, div,
}; };
use super::{Scrollbar, ScrollbarAxis}; use super::{Scrollbar, ScrollbarAxis};
use crate::scroll::ScrollbarHandle;
use crate::StyledExt; use crate::StyledExt;
use crate::scroll::ScrollbarHandle;
/// A trait for elements that can be made scrollable with scrollbars. /// A trait for elements that can be made scrollable with scrollbars.
pub trait ScrollableElement: InteractiveElement + Styled + ParentElement + Element { pub trait ScrollableElement: InteractiveElement + Styled + ParentElement + Element {
@@ -160,6 +160,7 @@ where
} }
impl ScrollableElement for Div {} impl ScrollableElement for Div {}
impl<E> ScrollableElement for Stateful<E> impl<E> ScrollableElement for Stateful<E>
where where
E: ParentElement + Styled + Element, E: ParentElement + Styled + Element,
@@ -195,6 +196,7 @@ fn render_scrollbar<H: ScrollbarHandle + Clone>(
// Do not render scrollbar when inspector is picking elements, // Do not render scrollbar when inspector is picking elements,
// to allow us to pick the background elements. // to allow us to pick the background elements.
let is_inspector_picking = window.is_inspector_picking(cx); let is_inspector_picking = window.is_inspector_picking(cx);
if is_inspector_picking { if is_inspector_picking {
return div(); return div();
} }

View File

@@ -5,11 +5,11 @@ use std::rc::Rc;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use gpui::{ use gpui::{
fill, point, px, relative, size, App, Axis, BorderStyle, Bounds, ContentMask, Corner, App, Axis, BorderStyle, Bounds, ContentMask, Corner, CursorStyle, Edges, Element, ElementId,
CursorStyle, Edges, Element, ElementId, GlobalElementId, Hitbox, HitboxBehavior, Hsla, GlobalElementId, Hitbox, HitboxBehavior, Hsla, InspectorElementId, IntoElement, IsZero,
InspectorElementId, IntoElement, IsZero, LayoutId, ListState, MouseDownEvent, MouseMoveEvent, LayoutId, ListState, MouseDownEvent, MouseMoveEvent, MouseUpEvent, PaintQuad, Pixels, Point,
MouseUpEvent, PaintQuad, Pixels, Point, Position, ScrollHandle, ScrollWheelEvent, Size, Style, Position, ScrollHandle, ScrollWheelEvent, Size, Style, UniformListScrollHandle, Window, fill,
UniformListScrollHandle, Window, point, px, relative, size,
}; };
use theme::{ActiveTheme, ScrollbarMode}; use theme::{ActiveTheme, ScrollbarMode};
@@ -407,7 +407,6 @@ impl Scrollbar {
ScrollbarMode::Scrolling => (THUMB_WIDTH, THUMB_INSET, THUMB_RADIUS), ScrollbarMode::Scrolling => (THUMB_WIDTH, THUMB_INSET, THUMB_RADIUS),
_ => (THUMB_ACTIVE_WIDTH, THUMB_ACTIVE_INSET, THUMB_ACTIVE_RADIUS), _ => (THUMB_ACTIVE_WIDTH, THUMB_ACTIVE_INSET, THUMB_ACTIVE_RADIUS),
}; };
( (
cx.theme().scrollbar_thumb_background, cx.theme().scrollbar_thumb_background,
cx.theme().scrollbar_track_background, cx.theme().scrollbar_track_background,
@@ -522,6 +521,7 @@ impl Element for Scrollbar {
let mut states = vec![]; let mut states = vec![];
let mut has_both = self.axis.is_both(); let mut has_both = self.axis.is_both();
let scroll_size = self let scroll_size = self
.scroll_size .scroll_size
.unwrap_or(self.scroll_handle.content_size()); .unwrap_or(self.scroll_handle.content_size());