fitness: fix workout name input losing characters during sync
All checks were successful
CI / update (push) Successful in 2m12s
All checks were successful
CI / update (push) Successful in 2m12s
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.
This commit is contained in:
@@ -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 @@
|
||||
<input
|
||||
class="workout-name-input"
|
||||
type="text"
|
||||
bind:value={workout.name}
|
||||
bind:value={nameInput}
|
||||
onfocus={() => { nameEditing = true; }}
|
||||
onblur={() => { nameEditing = false; workout.name = nameInput; }}
|
||||
onkeydown={(e) => { if (e.key === 'Enter') e.target.blur(); }}
|
||||
placeholder="Workout name"
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user