mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-18 18:08:07 +03:00
Focus toggled elements when interacting with the sidebars
Also, restore focus on the workspace when there is no active item on the sidebar that was just toggled.
This commit is contained in:
parent
1489c865e7
commit
386631debf
@ -2857,6 +2857,12 @@ impl Clone for AnyViewHandle {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&AnyViewHandle> for AnyViewHandle {
|
||||
fn from(handle: &AnyViewHandle) -> Self {
|
||||
handle.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: View> From<&ViewHandle<T>> for AnyViewHandle {
|
||||
fn from(handle: &ViewHandle<T>) -> Self {
|
||||
handle
|
||||
|
@ -214,6 +214,10 @@ impl View for ChatPanel {
|
||||
.with_style(&theme.chat_panel.container)
|
||||
.boxed()
|
||||
}
|
||||
|
||||
fn on_focus(&mut self, cx: &mut ViewContext<Self>) {
|
||||
cx.focus(&self.input_editor);
|
||||
}
|
||||
}
|
||||
|
||||
fn format_timestamp(mut timestamp: OffsetDateTime, mut now: OffsetDateTime) -> String {
|
||||
|
@ -767,6 +767,11 @@ impl Workspace {
|
||||
Side::Right => &mut self.right_sidebar,
|
||||
};
|
||||
sidebar.toggle_item(action.0.item_index);
|
||||
if let Some(active_item) = sidebar.active_item() {
|
||||
cx.focus(active_item);
|
||||
} else {
|
||||
cx.focus_self();
|
||||
}
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ impl Sidebar {
|
||||
if self.active_item_ix == Some(item_ix) {
|
||||
self.active_item_ix = None;
|
||||
} else {
|
||||
self.active_item_ix = Some(item_ix)
|
||||
self.active_item_ix = Some(item_ix);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user