collab panel: Unfocus filter editor on escape (#16579)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run

This has been bugging me for a while, because it meant I was stuck in
the collab panel when I accidentally navigated there via keyboard
shortcuts.

Now I can press esc and get out of that state.

Release Notes:

- Fixed `esc` not removing focus from the filter editor in the
collaboration panel.

### Before


https://github.com/user-attachments/assets/3bebac03-0e6a-49b0-9823-d9f3190aa5d2


### After


https://github.com/user-attachments/assets/d04c309d-9d1c-44b6-abd3-d48f55207e31
This commit is contained in:
Thorsten Ball 2024-08-21 09:38:12 +02:00 committed by GitHub
parent f1778dd9de
commit 28568429aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1395,15 +1395,22 @@ impl CollabPanel {
cx.notify();
}
fn reset_filter_editor_text(&mut self, cx: &mut ViewContext<Self>) -> bool {
self.filter_editor.update(cx, |editor, cx| {
if editor.buffer().read(cx).len(cx) > 0 {
editor.set_text("", cx);
true
} else {
false
}
})
}
fn cancel(&mut self, _: &Cancel, cx: &mut ViewContext<Self>) {
if self.take_editing_state(cx) {
cx.focus_view(&self.filter_editor);
} else {
self.filter_editor.update(cx, |editor, cx| {
if editor.buffer().read(cx).len(cx) > 0 {
editor.set_text("", cx);
}
});
} else if !self.reset_filter_editor_text(cx) {
self.focus_handle.focus(cx);
}
if self.context_menu.is_some() {