Unfocus grid item on escape

This commit is contained in:
Jeremy Soller 2024-02-29 20:53:15 -07:00
parent 7a96f51cbe
commit 2472f9909b
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
2 changed files with 6 additions and 1 deletions

View file

@ -677,7 +677,12 @@ impl Application for App {
return Command::none();
}
let had_focused_button = tab.select_focus_id().is_some();
if tab.select_none() {
if had_focused_button {
// Unfocus if there was a focused button
return widget::button::focus(widget::Id::unique());
}
return Command::none();
}
}

View file

@ -743,7 +743,7 @@ impl Tab {
}
}
fn select_focus_id(&self) -> Option<widget::Id> {
pub fn select_focus_id(&self) -> Option<widget::Id> {
let items = self.items_opt.as_ref()?;
let item = items.get(self.select_focus?)?;
Some(item.button_id.clone())