Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui: Fix scroll area to support two-layer scrolling in different directions (#31062)
Jason Leed9efa2860fef
diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rsindex d962ee9f56a..2411b26ff13 100644--- a/crates/editor/src/hover_popover.rs+++ b/crates/editor/src/hover_popover.rs@@ -869,6 +869,7 @@ impl InfoPopover {let keyboard_grace = Rc::clone(&self.keyboard_grace);div().id("info_popover")+ .occlude().elevation_2(cx)// Prevent a mouse down/move on the popover from being propagated to the editor,// because that would dismiss the popover.diff --git a/crates/gpui/examples/scrollable.rs b/crates/gpui/examples/scrollable.rsnew file mode 100644index 00000000000..b668c19c40a--- /dev/null+++ b/crates/gpui/examples/scrollable.rs@@ -0,0 +1,60 @@+use gpui::{+ App, Application, Bounds, Context, Window, WindowBounds, WindowOptions, div, prelude::*, px,+ size,+};++struct Scrollable {}++impl Render for Scrollable {+ fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {+ div()+ .size_full()+ .id("vertical")+ .p_4()+ .overflow_scroll()+ .bg(gpui::white())+ .child("Example for test 2 way scroll in nested layout")+ .child(+ div()+ .h(px(5000.))+ .border_1()+ .border_color(gpui::blue())+ .bg(gpui::blue().opacity(0.05))+ .p_4()+ .child(+ div()+ .mb_5()+ .w_full()+ .id("horizontal")+ .overflow_scroll()+ .child(+ div()+ .w(px(2000.))+ .h(px(150.))+ .bg(gpui::green().opacity(0.1))+ .hover(|this| this.bg(gpui::green().opacity(0.2)))+ .border_1()+ .border_color(gpui::green())+ .p_4()+ .child("Scroll Horizontal"),+ ),+ )+ .child("Scroll Vertical"),+ )+ }+}++fn main() {+ Application::new().run(|cx: &mut App| {+ let bounds = Bounds::centered(None, size(px(500.), px(500.0)), cx);+ cx.open_window(+ WindowOptions {+ window_bounds: Some(WindowBounds::Windowed(bounds)),+ ..Default::default()+ },+ |_, cx| cx.new(|_| Scrollable {}),+ )+ .unwrap();+ cx.activate(true);+ });+}diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rsindex fd78591dd16..3e9d1e27a93 100644--- a/crates/gpui/src/elements/div.rs+++ b/crates/gpui/src/elements/div.rs@@ -2299,7 +2299,6 @@ impl Interactivity {}scroll_offset.y += delta_y;scroll_offset.x += delta_x;- cx.stop_propagation();if *scroll_offset != old_scroll_offset {cx.notify(current_view);}