mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-20 08:08:58 +00:00
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 <noreply@anthropic.com> * fix: let a rename save close only the rename session it was started from --------- Co-authored-by: Ruben Fiszel <ruben@windmill.dev> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
Ruben Fiszel
parent
1c78f8d7a3
commit
2b8a0790a0
@@ -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 }}
|
||||
|
||||
Reference in New Issue
Block a user