From 391c42aa1848d6f7f5dfa5325fc5ea0a8057f18c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Apr 2026 16:26:29 +0000 Subject: [PATCH] fix(rename): imperatively focus + select rename inputs Svelte's native autofocus attribute is unreliable for inputs rendered via conditional blocks (prior smoke-test fixed this for the new-list input). Apply the same bind:this + $effect pattern to the list-rename input (TasksScreen) and the workspace-rename input (SettingsScreen), and select() the existing text so typing replaces the old name cleanly. --- apps/tauri/src/lib/screens/SettingsScreen.svelte | 12 +++++++++++- apps/tauri/src/lib/screens/TasksScreen.svelte | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/tauri/src/lib/screens/SettingsScreen.svelte b/apps/tauri/src/lib/screens/SettingsScreen.svelte index 9e9e581..d99ff7c 100644 --- a/apps/tauri/src/lib/screens/SettingsScreen.svelte +++ b/apps/tauri/src/lib/screens/SettingsScreen.svelte @@ -19,9 +19,19 @@ let renaming = $state(false); let renameValue = $state(""); + let renameInput = $state(null); let showKebab = $state(false); let confirmRename = $state(false); + // Imperative focus — Svelte's native autofocus attribute is unreliable + // for inputs that appear only via conditional blocks. + $effect(() => { + if (renaming && renameInput) { + renameInput.focus(); + renameInput.select(); + } + }); + // Load stored credentials exactly once for this workspace. Previously this // ran on every `ws.webdav_url` change, which silently clobbered in-progress // user edits whenever any other setting updated the config. @@ -133,11 +143,11 @@ {#if renaming} { if (e.key === "Enter") handleRename(); if (e.key === "Escape") { renaming = false; } }} onblur={handleRename} - autofocus /> {:else}

{ws?.name}

diff --git a/apps/tauri/src/lib/screens/TasksScreen.svelte b/apps/tauri/src/lib/screens/TasksScreen.svelte index 362bcdc..54b9a5c 100644 --- a/apps/tauri/src/lib/screens/TasksScreen.svelte +++ b/apps/tauri/src/lib/screens/TasksScreen.svelte @@ -58,6 +58,7 @@ let completedVisible = $state(false); let renamingListId = $state(null); let renameValue = $state(""); + let renameListInput = $state(null); let showListMenu = $state(false); let showSubtasks = $state(false); let confirmDeleteList = $state(false); @@ -85,6 +86,14 @@ if (showNewList && newListInput) newListInput.focus(); }); + // Same imperative-focus trick for the inline list-rename input. + $effect(() => { + if (renamingListId && renameListInput) { + renameListInput.focus(); + renameListInput.select(); + } + }); + async function handleNewList() { if (!newListName.trim()) return; @@ -631,11 +640,11 @@ {#if renamingListId === app.activeListId} { if (e.key === "Enter") handleRenameList(); if (e.key === "Escape") renamingListId = null; }} onblur={handleRenameList} - autofocus /> {:else}

{app.activeList?.title ?? "Tasks"}