diff --git a/crates/story/src/scrollable_story.rs b/crates/story/src/scrollable_story.rs index 6e0216bc..a44eeb7c 100644 --- a/crates/story/src/scrollable_story.rs +++ b/crates/story/src/scrollable_story.rs @@ -183,8 +183,8 @@ impl Render for ScrollableStory { .child( v_flex() .id("test-1") - .focusable() .scrollable(cx.view().clone(), ScrollbarAxis::Vertical) + .focusable() .p_3() .w(test_width) .gap_1() diff --git a/crates/ui/src/scroll/scrollable.rs b/crates/ui/src/scroll/scrollable.rs index 4cd148d0..2d83ab36 100644 --- a/crates/ui/src/scroll/scrollable.rs +++ b/crates/ui/src/scroll/scrollable.rs @@ -2,9 +2,9 @@ use std::{cell::Cell, rc::Rc}; use super::{Scrollbar, ScrollbarAxis, ScrollbarState}; use gpui::{ - canvas, div, relative, AnyElement, AnyView, Element, ElementId, GlobalElementId, - InteractiveElement as _, IntoElement, ParentElement, Pixels, Position, ScrollHandle, - SharedString, Size, StatefulInteractiveElement, Style, StyleRefinement, Styled, WindowContext, + canvas, div, relative, AnyElement, AnyView, Div, Element, ElementId, GlobalElementId, + InteractiveElement, IntoElement, ParentElement, Pixels, Position, ScrollHandle, SharedString, + Size, Stateful, StatefulInteractiveElement, Style, StyleRefinement, Styled, WindowContext, }; /// A scroll view is a container that allows the user to scroll through a large amount of content. @@ -13,8 +13,8 @@ pub struct Scrollable { element: Option, view: AnyView, axis: ScrollbarAxis, - /// This is not used yet. - _style: StyleRefinement, + /// This is a fake element to handle Styled, InteractiveElement, not used. + _element: Stateful
, } impl Scrollable @@ -31,10 +31,10 @@ where Self { element: Some(element), + _element: div().id("fake"), id, view, axis, - _style: StyleRefinement::default(), } } @@ -105,11 +105,25 @@ where if let Some(element) = &mut self.element { element.style() } else { - &mut self._style + self._element.style() } } } +impl InteractiveElement for Scrollable +where + E: Element + InteractiveElement, +{ + fn interactivity(&mut self) -> &mut gpui::Interactivity { + if let Some(element) = &mut self.element { + element.interactivity() + } else { + self._element.interactivity() + } + } +} +impl StatefulInteractiveElement for Scrollable where E: Element + StatefulInteractiveElement {} + impl IntoElement for Scrollable where E: Element,