From 7c6b34cb73df3f78839a03013f2a796d77b9b839 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 15 Feb 2024 15:57:32 +0200 Subject: [PATCH] Close modals and menus before dispathing actions (#7830) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/zed-industries/zed/issues/7799 by forcing the modal to close before dispatching the action. While not needed specifically for this case, changed the context menus to do the same, to be uniform — context menu actions seem to work properly after this change too. Release Notes: - Fixed markdown preview action not working ([7799](https://github.com/zed-industries/zed/issues/7799)) --- crates/command_palette/src/command_palette.rs | 2 +- crates/ui/src/components/context_menu.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rs index 50ededd122..c47614743e 100644 --- a/crates/command_palette/src/command_palette.rs +++ b/crates/command_palette/src/command_palette.rs @@ -317,8 +317,8 @@ impl PickerDelegate for CommandPaletteDelegate { }); let action = command.action; cx.focus(&self.previous_focus_handle); - cx.dispatch_action(action); self.dismissed(cx); + cx.dispatch_action(action); } fn render_match( diff --git a/crates/ui/src/components/context_menu.rs b/crates/ui/src/components/context_menu.rs index e3a7aeefda..23a6a5e168 100644 --- a/crates/ui/src/components/context_menu.rs +++ b/crates/ui/src/components/context_menu.rs @@ -224,8 +224,8 @@ impl ContextMenu { .timer(Duration::from_millis(50)) .await; this.update(&mut cx, |this, cx| { + this.cancel(&menu::Cancel, cx); cx.dispatch_action(action); - this.cancel(&menu::Cancel, cx) }) }) .detach_and_log_err(cx);