diff --git a/gui/NewAgentDialog.qml b/gui/NewAgentDialog.qml index ca9880d..9e12fcc 100644 --- a/gui/NewAgentDialog.qml +++ b/gui/NewAgentDialog.qml @@ -162,5 +162,8 @@ Dialog { } } - onOpened: errorLabel.text = "" + onOpened: { + errorLabel.text = "" + dirField.forceActiveFocus() + } } diff --git a/gui/NewSessionDialog.qml b/gui/NewSessionDialog.qml index 4cdd374..a61fba6 100644 --- a/gui/NewSessionDialog.qml +++ b/gui/NewSessionDialog.qml @@ -75,5 +75,6 @@ Dialog { errorLabel.text = "" nameField.text = "" remoteField.text = "" + nameField.forceActiveFocus() } } diff --git a/gui/main.qml b/gui/main.qml index fd1261f..118c12d 100644 --- a/gui/main.qml +++ b/gui/main.qml @@ -102,7 +102,7 @@ ApplicationWindow { function buildSessionTree() { // Full rebuild - used on initial load - var hadFocus = promptInput.activeFocus + var focusItem = root.activeFocusItem sessionTreeModel.clear() modelCache = {} var sessions = ollie.sessions @@ -139,8 +139,9 @@ ApplicationWindow { appendSessionToModel(sess) } - if (hadFocus) - promptInput.forceActiveFocus() + // Restore focus to whatever had it (handles dialogs, not just promptInput) + if (focusItem && focusItem.visible) + focusItem.forceActiveFocus() } // Compute connection color from session data (avoids C++ call) @@ -197,7 +198,7 @@ ApplicationWindow { function updateSessionTree() { // Incremental update - diff old vs new - var hadFocus = promptInput.activeFocus + var focusItem = root.activeFocusItem var sessions = ollie.sessions // Build lookup of new sessions @@ -232,8 +233,9 @@ ApplicationWindow { } } - if (hadFocus) - promptInput.forceActiveFocus() + // Restore focus to whatever had it (handles dialogs, not just promptInput) + if (focusItem && focusItem.visible) + focusItem.forceActiveFocus() } function findSessionIndex(sessionId) {