From f1957b1737648429d2272f001abc995067027dce Mon Sep 17 00:00:00 2001 From: Mikayla Date: Mon, 7 Aug 2023 13:31:09 -0700 Subject: [PATCH] Push focus and fix keybindings --- assets/keymaps/default.json | 8 +++- .../src/collab_panel/channel_modal.rs | 45 ++++++++++--------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index d99a660850..11cc50a03e 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -553,8 +553,12 @@ { "context": "ChannelModal", "bindings": { - "left": "channel_modal::SelectNextControl", - "right": "channel_modal::SelectNextControl", + "tab": "channel_modal::ToggleMode" + } + }, + { + "context": "ChannelModal > Picker > Editor", + "bindings": { "tab": "channel_modal::ToggleMode" } }, diff --git a/crates/collab_ui/src/collab_panel/channel_modal.rs b/crates/collab_ui/src/collab_panel/channel_modal.rs index 1b1a50dbe4..f1775eb084 100644 --- a/crates/collab_ui/src/collab_panel/channel_modal.rs +++ b/crates/collab_ui/src/collab_panel/channel_modal.rs @@ -16,7 +16,7 @@ actions!(channel_modal, [SelectNextControl, ToggleMode]); pub fn init(cx: &mut AppContext) { Picker::::init(cx); cx.add_action(ChannelModal::toggle_mode); - cx.add_action(ChannelModal::select_next_control); + // cx.add_action(ChannelModal::select_next_control); } pub struct ChannelModal { @@ -64,6 +64,7 @@ impl ChannelModal { }); cx.subscribe(&picker, |_, _, e, cx| cx.emit(*e)).detach(); + let has_focus = picker.read(cx).has_focus(); Self { @@ -105,29 +106,30 @@ impl ChannelModal { picker.update_matches(picker.query(cx), cx); cx.notify() }); + cx.notify() }) }) .detach(); } - fn select_next_control(&mut self, _: &SelectNextControl, cx: &mut ViewContext) { - self.picker.update(cx, |picker, cx| { - let delegate = picker.delegate_mut(); - match delegate.mode { - Mode::ManageMembers => match delegate.selected_column { - Some(UserColumn::Remove) => { - delegate.selected_column = Some(UserColumn::ToggleAdmin) - } - Some(UserColumn::ToggleAdmin) => { - delegate.selected_column = Some(UserColumn::Remove) - } - None => todo!(), - }, - Mode::InviteMembers => {} - } - cx.notify() - }); - } + // fn select_next_control(&mut self, _: &SelectNextControl, cx: &mut ViewContext) { + // self.picker.update(cx, |picker, cx| { + // let delegate = picker.delegate_mut(); + // match delegate.mode { + // Mode::ManageMembers => match delegate.selected_column { + // Some(UserColumn::Remove) => { + // delegate.selected_column = Some(UserColumn::ToggleAdmin) + // } + // Some(UserColumn::ToggleAdmin) => { + // delegate.selected_column = Some(UserColumn::Remove) + // } + // None => todo!(), + // }, + // Mode::InviteMembers => {} + // } + // cx.notify() + // }); + // } } impl Entity for ChannelModal { @@ -209,8 +211,11 @@ impl View for ChannelModal { .into_any() } - fn focus_in(&mut self, _: gpui::AnyViewHandle, _: &mut ViewContext) { + fn focus_in(&mut self, _: gpui::AnyViewHandle, cx: &mut ViewContext) { self.has_focus = true; + if cx.is_self_focused() { + cx.focus(&self.picker) + } } fn focus_out(&mut self, _: gpui::AnyViewHandle, _: &mut ViewContext) {