From 9547da2b25be00b8df028881374da920bbf88040 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 6 Apr 2026 20:33:43 -0400 Subject: [PATCH] fix: reset focus when opening a new tab --- src/app.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/app.rs b/src/app.rs index 1eee6f4..6bac6f3 100644 --- a/src/app.rs +++ b/src/app.rs @@ -32,7 +32,8 @@ use cosmic::{ widget::scrollable, window::{self, Event as WindowEvent, Id as WindowId}, }, - iced_runtime::clipboard, + iced_core::widget::operation::focusable::unfocus, + iced_runtime::{clipboard, task}, iced_widget::{button::focus, scrollable::AbsoluteOffset}, style, surface, theme, widget::{ @@ -1177,14 +1178,14 @@ impl App { entity.id() }; - ( - entity, - Task::batch([ - self.update_title(), - self.update_watcher(), - self.update_tab(entity, location, selection_paths), - ]), - ) + let mut tasks = Vec::with_capacity(4); + if activate { + tasks.push(task::widget(unfocus())); + } + tasks.push(self.update_title()); + tasks.push(self.update_watcher()); + tasks.push(self.update_tab(entity, location, selection_paths)); + (entity, Task::batch(tasks)) } fn open_tab(