From 82c4c3946254924a0b38c7271a59c342e38374d6 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Fri, 20 Mar 2026 16:20:48 +0100 Subject: [PATCH] fitness: fix workout name input losing characters during sync Decouple name input from live sync by using a local variable that only commits to workout state on blur/Enter. Remote name updates are applied only when the input is not focused, preventing the sync layer from overwriting in-progress edits. --- src/routes/fitness/workout/active/+page.svelte | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/routes/fitness/workout/active/+page.svelte b/src/routes/fitness/workout/active/+page.svelte index 086b45a..6bec03f 100644 --- a/src/routes/fitness/workout/active/+page.svelte +++ b/src/routes/fitness/workout/active/+page.svelte @@ -12,6 +12,9 @@ const workout = getWorkout(); const sync = getWorkoutSync(); + let nameInput = $state(workout.name); + let nameEditing = $state(false); + $effect(() => { if (!nameEditing) nameInput = workout.name; }); let showPicker = $state(false); let restExerciseIdx = $state(-1); let restSetIdx = $state(-1); @@ -339,7 +342,10 @@ { nameEditing = true; }} + onblur={() => { nameEditing = false; workout.name = nameInput; }} + onkeydown={(e) => { if (e.key === 'Enter') e.target.blur(); }} placeholder="Workout name" />