From 2b8a0790a0a973240ca32c5fba0a23339fc21fda Mon Sep 17 00:00:00 2001 From: Raunak Burrows Date: Thu, 19 Nov 2026 09:03:07 +0000 Subject: [PATCH] fix: put a saved input's name back when its rename is cancelled (#12483) * fix: put a saved input's name back when its rename is cancelled The rename field in the Saved Inputs list is bound to the listed input itself. Pressing Escape, or opening the rename of another input, ended the edit without saving but left the typed text as the input's name, so the list showed a name the server never stored until the page was reloaded. Remember the name when the edit starts and restore it when the edit is cancelled; saving with Enter or the pencil button is unchanged. * fix: keep a saved input's new name when Escape is pressed during its save * fix: keep a saved input's name while its rename is saving, and keep another row's rename open Co-Authored-By: Claude Opus 5.5 * fix: let a rename save close only the rename session it was started from --------- Co-authored-by: Ruben Fiszel Co-authored-by: Claude Opus 5.5 --- .../src/lib/components/SavedInputsPicker.svelte | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/SavedInputsPicker.svelte b/frontend/src/lib/components/SavedInputsPicker.svelte index 4749c6745f..38b9df414f 100644 --- a/frontend/src/lib/components/SavedInputsPicker.svelte +++ b/frontend/src/lib/components/SavedInputsPicker.svelte @@ -162,7 +162,7 @@ function handleKeydown(event: KeyboardEvent) { if (event.key === 'Escape' && isEditing) { - setEditing(null) + setEditing(null, true) event.stopPropagation() event.preventDefault() } else if (event.key === 'Escape' && selectedInput) { @@ -172,15 +172,24 @@ } if (event.key === 'Enter' && isEditing) { + const session = editSession updateInput(isEditing).then(() => { - setEditing(null) + // a rename opened while this one was saving, even of the same row, stays open + if (editSession === session) setEditing(null) }) event.stopPropagation() event.preventDefault() } } - function setEditing(input: EditableInput | null) { + // The rename field edits the listed input itself, so a cancelled rename must put its name back, + // unless its save is in flight: that has already sent the new name. + let nameBeforeEdit = '' + let editSession = 0 + function setEditing(input: EditableInput | null, cancel = false) { + editSession++ + if (cancel && isEditing && !isEditing.isSaving) isEditing.name = nameBeforeEdit + nameBeforeEdit = input?.name ?? '' isEditing = input dispatch('isEditing', !!input) } @@ -331,7 +340,7 @@ updateInput(isEditing) setEditing(null) } else { - setEditing(item) + setEditing(item, true) } }} startIcon={{ icon: Pencil }}