Skip to content

Commit

Permalink
Fix project panel context menu (#3495)
Browse files Browse the repository at this point in the history
Release Notes:

- N/A
  • Loading branch information
ConradIrwin authored Dec 5, 2023
2 parents 13bb165 + 9162f29 commit 45992b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 7 additions & 4 deletions crates/gpui2/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1497,10 +1497,13 @@ impl<'a> WindowContext<'a> {
}

pub fn bindings_for_action(&self, action: &dyn Action) -> Vec<KeyBinding> {
self.window.current_frame.dispatch_tree.bindings_for_action(
action,
&self.window.current_frame.dispatch_tree.context_stack,
)
self.window
.previous_frame
.dispatch_tree
.bindings_for_action(
action,
&self.window.previous_frame.dispatch_tree.context_stack,
)
}

pub fn bindings_for_action_in(
Expand Down
5 changes: 4 additions & 1 deletion crates/ui2/src/components/context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct ContextMenu {
items: Vec<ContextMenuItem>,
focus_handle: FocusHandle,
selected_index: Option<usize>,
delayed: bool,
}

impl FocusableView for ContextMenu {
Expand All @@ -46,6 +47,7 @@ impl ContextMenu {
items: Default::default(),
focus_handle: cx.focus_handle(),
selected_index: None,
delayed: false,
},
cx,
)
Expand Down Expand Up @@ -165,6 +167,7 @@ impl ContextMenu {
}
}) {
self.selected_index = Some(ix);
self.delayed = true;
cx.notify();
let action = dispatched.boxed_clone();
cx.spawn(|this, mut cx| async move {
Expand Down Expand Up @@ -205,7 +208,7 @@ impl Render for ContextMenu {
.on_action(cx.listener(ContextMenu::select_prev))
.on_action(cx.listener(ContextMenu::confirm))
.on_action(cx.listener(ContextMenu::cancel))
.map(|mut el| {
.when(!self.delayed, |mut el| {
for item in self.items.iter() {
if let ContextMenuItem::Entry {
action: Some(action),
Expand Down

0 comments on commit 45992b0

Please sign in to comment.