From c9521564918e6488eeca4ff054b141dc7ba2aa65 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 19 Apr 2026 07:13:29 +0000 Subject: [PATCH] refactor(date-picker): group selected-state declarations up top selectedYear/selectedMonth were declared below selectDay, which writes to them, and below isToday, which is declared nearby. Runtime worked because the assignments only run on user click (after script init), but the split made the initialization order confusing. Group all $state fields at the top of the script. --- apps/tauri/src/lib/components/DateTimePicker.svelte | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/tauri/src/lib/components/DateTimePicker.svelte b/apps/tauri/src/lib/components/DateTimePicker.svelte index a86d791..39da8ad 100644 --- a/apps/tauri/src/lib/components/DateTimePicker.svelte +++ b/apps/tauri/src/lib/components/DateTimePicker.svelte @@ -13,6 +13,8 @@ let viewYear = $state(existing ? existing.getFullYear() : now.getFullYear()); let viewMonth = $state(existing ? existing.getMonth() : now.getMonth()); let selectedDay = $state(existing ? existing.getDate() : now.getDate()); + let selectedYear = $state(existing ? existing.getFullYear() : now.getFullYear()); + let selectedMonth = $state(existing ? existing.getMonth() : now.getMonth()); let includeTime = $state(has_time); let selectedHour = $state(existing ? existing.getHours() : now.getHours()); let selectedMinute = $state(existing ? existing.getMinutes() : 0); @@ -58,9 +60,6 @@ return `${viewYear}-${viewMonth + 1}-${day}` === todayStr; } - let selectedYear = $state(existing ? existing.getFullYear() : now.getFullYear()); - let selectedMonth = $state(existing ? existing.getMonth() : now.getMonth()); - function isSelected(day: number): boolean { return selectedDay === day && selectedYear === viewYear && selectedMonth === viewMonth; }