Close modals and menus before dispathing actions (#7830)

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))
This commit is contained in:
Kirill Bulatov 2024-02-15 15:57:32 +02:00 committed by GitHub
parent 3921259b6c
commit 7c6b34cb73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -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(

View File

@ -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);