From 5426d08fb07b0f97a9934ac87e3926ab41266d9f Mon Sep 17 00:00:00 2001 From: milanofthe Date: Wed, 18 Nov 2026 14:16:13 +0100 Subject: [PATCH] Entry fields commit on change, not on every keystroke --- src/lib/actions/paramInput.ts | 24 +++++++++++++++---- .../dialogs/BlockPropertiesDialog.svelte | 4 ++-- .../dialogs/EventPropertiesDialog.svelte | 4 ++-- src/lib/components/nodes/BaseNode.svelte | 2 +- .../components/panels/SimulationPanel.svelte | 14 +++++------ src/lib/utils/focus.ts | 9 +++++++ src/routes/editor/+page.svelte | 8 ++++++- 7 files changed, 48 insertions(+), 17 deletions(-) diff --git a/src/lib/actions/paramInput.ts b/src/lib/actions/paramInput.ts index 288b34ee..7a91bb0d 100644 --- a/src/lib/actions/paramInput.ts +++ b/src/lib/actions/paramInput.ts @@ -1,18 +1,24 @@ /** - * Svelte action for consistent keyboard handling on parameter inputs. + * Svelte action for entry fields: parameters, names and settings. + * + * An entry is committed by the `change` event of the field, which fires on + * Enter or when the field is left, and only if the value changed. Fields + * listen to `onchange`, not `oninput`, so a half typed value is never + * committed: no undo step, live mutation or evaluation per keystroke. * * Features: - * - Escape: unfocus (blur) the input, stops propagation + * - Escape: restore the value the field had when it was focused and unfocus + * it, so no `change` fires and nothing is committed; stops propagation * - Enter: optionally blur (for single-line inputs, not textareas) * * Usage: - * + * commit(e.currentTarget.value)} use:paramInput /> * *