mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 10:42:08 +00:00
Avoid retrieving layout bounds inside of right click menu event handler (#4056)
By the time the event handler is invoked, all information about the rendered layout tree is gone. Release Notes: - N/A
This commit is contained in:
commit
1b35b93e77
1 changed files with 2 additions and 3 deletions
|
@ -134,6 +134,7 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
|
||||||
let position = element_state.position.clone();
|
let position = element_state.position.clone();
|
||||||
let attach = self.attach.clone();
|
let attach = self.attach.clone();
|
||||||
let child_layout_id = element_state.child_layout_id.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| {
|
cx.on_mouse_event(move |event: &MouseDownEvent, phase, cx| {
|
||||||
if phase == DispatchPhase::Bubble
|
if phase == DispatchPhase::Bubble
|
||||||
|
@ -161,9 +162,7 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
|
||||||
*menu.borrow_mut() = Some(new_menu);
|
*menu.borrow_mut() = Some(new_menu);
|
||||||
|
|
||||||
*position.borrow_mut() = if attach.is_some() && child_layout_id.is_some() {
|
*position.borrow_mut() = if attach.is_some() && child_layout_id.is_some() {
|
||||||
attach
|
attach.unwrap().corner(child_bounds)
|
||||||
.unwrap()
|
|
||||||
.corner(cx.layout_bounds(child_layout_id.unwrap()))
|
|
||||||
} else {
|
} else {
|
||||||
cx.mouse_position()
|
cx.mouse_position()
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue