diff --git a/src/app.rs b/src/app.rs index b35a849..bf98fc9 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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(); } } diff --git a/src/tab.rs b/src/tab.rs index 78b90a9..8b04014 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -743,7 +743,7 @@ impl Tab { } } - fn select_focus_id(&self) -> Option { + pub fn select_focus_id(&self) -> Option { let items = self.items_opt.as_ref()?; let item = items.get(self.select_focus?)?; Some(item.button_id.clone())