From d909b50989f7579aa23c44f53ed121c4c59ccdff Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 3 Mar 2026 23:44:03 +0100 Subject: [PATCH] fix(frontend): wait for window focus before focusing quick entry input The v-focus directive fires when the input mounts, but in the Electron quick entry window the page loads before the window is shown. This means focus() is called on a hidden window and has no effect. Now check document.hasFocus() and if the window isn't focused yet, defer the focus call to when the window receives focus. --- .../components/quick-actions/QuickActions.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/quick-actions/QuickActions.vue b/frontend/src/components/quick-actions/QuickActions.vue index 025932e3e..19f80f752 100644 --- a/frontend/src/components/quick-actions/QuickActions.vue +++ b/frontend/src/components/quick-actions/QuickActions.vue @@ -186,7 +186,21 @@ watchEffect(() => { watchEffect(() => { if (active.value && isQuickAddMode) { selectedCmd.value = commands.value.newTask - nextTick(() => searchInput.value?.focus()) + + // The Electron window may not be visible yet when Vue mounts + // (it's shown after did-finish-load). Try focusing now, and if + // the window doesn't have focus yet, wait for it. + nextTick(() => { + if (document.hasFocus()) { + searchInput.value?.focus() + } else { + const focusOnWindowReady = () => { + searchInput.value?.focus() + window.removeEventListener('focus', focusOnWindowReady) + } + window.addEventListener('focus', focusOnWindowReady) + } + }) } })