From 00d8921ae9b10cae8762995f9d7985c84a271dd2 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 14 Nov 2023 19:22:41 -0700 Subject: [PATCH] Fix click events by notifying when we assign pending_mouse_down --- crates/gpui2/src/elements/div.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/gpui2/src/elements/div.rs b/crates/gpui2/src/elements/div.rs index f3f6385503..a08d1619ae 100644 --- a/crates/gpui2/src/elements/div.rs +++ b/crates/gpui2/src/elements/div.rs @@ -597,7 +597,7 @@ impl ParentComponent for Div { } impl Element for Div { - type ElementState = NodeState; + type ElementState = DivState; fn element_id(&self) -> Option { self.interactivity.element_id.clone() @@ -617,7 +617,7 @@ impl Element for Div { child.initialize(view_state, cx); } - NodeState { + DivState { interactive_state, child_layout_ids: SmallVec::new(), } @@ -706,7 +706,7 @@ impl Component for Div { } } -pub struct NodeState { +pub struct DivState { child_layout_ids: SmallVec<[LayoutId; 4]>, interactive_state: InteractiveElementState, } @@ -911,11 +911,13 @@ where } } *pending_mouse_down.lock() = None; + cx.notify(); }); } else { - cx.on_mouse_event(move |_state, event: &MouseDownEvent, phase, _cx| { + cx.on_mouse_event(move |_view_state, event: &MouseDownEvent, phase, cx| { if phase == DispatchPhase::Bubble && bounds.contains_point(&event.position) { *pending_mouse_down.lock() = Some(event.clone()); + cx.notify(); } }); }