From a56265e6073f35cba7b7a3add5e4c8ecabf0e32a Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 15 Jan 2024 19:27:18 +0100 Subject: [PATCH] Avoid retrieving layout bounds inside of right click menu event handler Co-Authored-By: Nathan Co-Authored-By: Max --- crates/ui/src/components/right_click_menu.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/ui/src/components/right_click_menu.rs b/crates/ui/src/components/right_click_menu.rs index 2404368f25..55cdd93a5b 100644 --- a/crates/ui/src/components/right_click_menu.rs +++ b/crates/ui/src/components/right_click_menu.rs @@ -134,6 +134,7 @@ impl Element for RightClickMenu { let position = element_state.position.clone(); let attach = self.attach.clone(); let child_layout_id = element_state.child_layout_id.clone(); + let child_bounds = cx.layout_bounds(child_layout_id.unwrap()); cx.on_mouse_event(move |event: &MouseDownEvent, phase, cx| { if phase == DispatchPhase::Bubble @@ -161,9 +162,7 @@ impl Element for RightClickMenu { *menu.borrow_mut() = Some(new_menu); *position.borrow_mut() = if attach.is_some() && child_layout_id.is_some() { - attach - .unwrap() - .corner(cx.layout_bounds(child_layout_id.unwrap())) + attach.unwrap().corner(child_bounds) } else { cx.mouse_position() };