From 18bdbab0ff554c8ad377aad22a9407e17d2633f0 Mon Sep 17 00:00:00 2001 From: Franklin Davis Date: Tue, 14 Jul 2026 05:35:30 +0000 Subject: [PATCH] fix: preserve date when manually entering the year Typing into the year section produces an intermediate Invalid Date that the picker was forwarding to the parent, clearing the whole field. Only propagate onChange for a complete valid date or a cleared field. Closes #5072 --- src/components/date_picker/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/date_picker/index.tsx b/src/components/date_picker/index.tsx index 9d2e5bb832c..e56a903d440 100644 --- a/src/components/date_picker/index.tsx +++ b/src/components/date_picker/index.tsx @@ -71,7 +71,12 @@ const DatePicker = ({ const isValidDate = value instanceof Date && isValid(value); - onChange?.(value); + // Only push a complete valid date or a fully cleared field up to the parent. + // A partial manual entry (e.g. while typing the year) arrives as an Invalid + // Date and would otherwise clear the stored value. + if (isValidDate || value === null) { + onChange?.(value); + } if (view === 'input' && !open && isValidDate) { setOpen(false);