From a8c0a30f29f240d833fa40c8119f39c06d176f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 4 Jun 2026 15:57:14 +0200 Subject: [PATCH] fix(dashboard): skip prefilled date pickers in the quick-entry dirty check A freshly-opened quick-entry sheet prefills its datetime-local field with the current time, so the dismiss-time dirty check read every pristine sheet as unsaved and always raised the discard confirm. Exclude date/time picker types from the scan; typed text and notes still count. --- src/app/page.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 54c4f31c8..8e1113e51 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -74,11 +74,20 @@ const DASHBOARD_QUERY_OPTS = { * dismiss (overlay tap, Esc, mobile swipe-down) discarding a partly * filled form. The forms live behind a stable `ResponsiveSheet` body * slot and don't expose their dirty state, so we read it from the DOM - * at dismiss time: any visible text/number/date input or textarea that + * at dismiss time: any visible text/number input or textarea that * carries a value, or any checked checkbox/radio that isn't a default, - * counts as unsaved input. Cheap, synchronous, and runs only on the - * one mounted sheet body. + * counts as unsaved input. Date/time pickers are excluded — the forms + * prefill them with the current timestamp on mount, so a pristine sheet + * would otherwise always read as dirty. Cheap, synchronous, and runs + * only on the one mounted sheet body. */ +const PREFILLED_PICKER_TYPES = new Set([ + "date", + "datetime-local", + "time", + "month", + "week", +]); function sheetBodyHasUnsavedInput(): boolean { if (typeof document === "undefined") return false; const body = document.querySelector( @@ -90,6 +99,9 @@ function sheetBodyHasUnsavedInput(): boolean { >("input, textarea"); for (const field of fields) { if (field.disabled || field.type === "hidden") continue; + // Skip pickers the form prefills with "now" — an untouched default + // is not user input (v1.11.3 QA H1). + if (PREFILLED_PICKER_TYPES.has(field.type)) continue; if (field.type === "checkbox" || field.type === "radio") { const box = field as HTMLInputElement; if (box.checked !== box.defaultChecked) return true;