From abdcab3c7dc7c8943d87d7356dc712b68647eae0 Mon Sep 17 00:00:00 2001 From: Petr Mironychev <9195189+Palm1r@users.noreply.github.com> Date: Wed, 27 May 2026 15:43:18 +0200 Subject: [PATCH] fix: Add focus guard --- ChatView/qml/RootItem.qml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ChatView/qml/RootItem.qml b/ChatView/qml/RootItem.qml index 5d94861..4f79079 100644 --- a/ChatView/qml/RootItem.qml +++ b/ChatView/qml/RootItem.qml @@ -589,6 +589,27 @@ ChatRootView { messageInput.forceActiveFocus() } + property Item focusGuard: Window.activeFocusItem + onFocusGuardChanged: Qt.callLater(returnFocusToInputIfNeeded) + + function returnFocusToInputIfNeeded() { + var item = Window.activeFocusItem + if (!item || item === messageInput) + return + if (item.cursorVisible !== undefined || item.selectByMouse !== undefined) + return + if (item.popup !== undefined) + return + var p = item + while (p) { + if (p === root) { + messageInput.forceActiveFocus() + return + } + p = p.parent + } + } + function applyMentionSelection() { var result = fileMentionPopup.applyCurrentSelection( messageInput.text, messageInput.cursorPosition, root.useTools)