From 0b4690afabe75a906bea6240241e7a285c1107b4 Mon Sep 17 00:00:00 2001 From: Luca <102960244+Luca-Timo@users.noreply.github.com> Date: Wed, 3 Jun 2026 17:50:13 +0200 Subject: [PATCH] fix(crm): commit LocalizedDateInput value live, not only on blur MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The historical-invoice import (and any form whose date field has a non-empty default like today) lost a typed date: the value was only pushed to the parent on blur, so submitting while the field was focused — or before React re-rendered after the blur-time setState — sent the stale default. Issued/ event dates came out as 'today' instead of the entered date. Now commit as soon as a complete, valid date is entered (toIso returns '' for partial input, so intermediate keystrokes emit nothing); blur still normalises display + handles clearing. Applies to every LocalizedDateInput consumer. --- .../src/components/common/LocalizedDateInput.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/common/LocalizedDateInput.tsx b/frontend/src/components/common/LocalizedDateInput.tsx index fdc3553b..77fef538 100644 --- a/frontend/src/components/common/LocalizedDateInput.tsx +++ b/frontend/src/components/common/LocalizedDateInput.tsx @@ -123,7 +123,19 @@ export const LocalizedDateInput: React.FC = ({ value={text} placeholder={placeholder} disabled={disabled} - onChange={(e) => setText(e.target.value)} + onChange={(e) => { + const next = e.target.value; + setText(next); + // Commit live as soon as a complete, valid date is typed — + // don't wait for blur. Otherwise a value entered then submitted + // without blurring (or before React re-renders after the + // blur-time setState) is lost and the parent keeps its previous + // value (e.g. the import form's "today" default). toIso returns + // '' for partial/invalid input, so intermediate keystrokes emit + // nothing. + const iso = toIso(next); + if (iso) onChange(iso); + }} onBlur={() => { const iso = toIso(text); if (iso) {