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
4 changed files with 16 additions and 1 deletions
|
@ -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 {
|
impl<T: View> From<&ViewHandle<T>> for AnyViewHandle {
|
||||||
fn from(handle: &ViewHandle<T>) -> Self {
|
fn from(handle: &ViewHandle<T>) -> Self {
|
||||||
handle
|
handle
|
||||||
|
|
|
@ -214,6 +214,10 @@ impl View for ChatPanel {
|
||||||
.with_style(&theme.chat_panel.container)
|
.with_style(&theme.chat_panel.container)
|
||||||
.boxed()
|
.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 {
|
fn format_timestamp(mut timestamp: OffsetDateTime, mut now: OffsetDateTime) -> String {
|
||||||
|
|
|
@ -767,6 +767,11 @@ impl Workspace {
|
||||||
Side::Right => &mut self.right_sidebar,
|
Side::Right => &mut self.right_sidebar,
|
||||||
};
|
};
|
||||||
sidebar.toggle_item(action.0.item_index);
|
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();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl Sidebar {
|
||||||
if self.active_item_ix == Some(item_ix) {
|
if self.active_item_ix == Some(item_ix) {
|
||||||
self.active_item_ix = None;
|
self.active_item_ix = None;
|
||||||
} else {
|
} else {
|
||||||
self.active_item_ix = Some(item_ix)
|
self.active_item_ix = Some(item_ix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue