feat(workouts): read a blank start as now minus the duration

Refs #1085. Logging a workout right after finishing it meant changing the
start first, or the form refused it as ending in the future. The start field
now opens blank; left blank, the workout is saved as starting the duration
before now. A start the person enters is validated as before.
This commit is contained in:
Marc-André Bombeck committed 2026-10-04 09:07:39 +02:00
1 parent 964a3d050c
commit 17b653b819
10 files changed
+53 -15

No files matched your search

@@ -276,12 +276,18 @@ export function ManualWorkoutForm({
value={draft.start}
onChange={(value) => update("start", value)}
max={wallClockNow(new Date(), timezone)}
required
aria-required="true"
aria-invalid={!!errors.start || undefined}
aria-describedby={describedBy("start", `${ids.start}-error`)}
aria-describedby={[
`${ids.start}-hint`,
describedBy("start", `${ids.start}-error`),
]
.filter(Boolean)
.join(" ")}
data-testid="manual-workout-start"
/>
<p id={`${ids.start}-hint`} className="text-muted-foreground text-xs">
{t("insights.workouts.manual.startHint")}
</p>
<FieldError id={`${ids.start}-error`} message={fieldError("start")} />
</div>