From 0c5d1dfa7ae9a3e2b54be61825fcd1583df93763 Mon Sep 17 00:00:00 2001 From: elliottc32 Date: Wed, 4 Dec 2024 11:48:45 -0600 Subject: [PATCH] Fixed the Calendar Bug where it doesn't close after choosing a Date (#37) --- src/main/frontend/src/components/CreateLoanDialog.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/frontend/src/components/CreateLoanDialog.tsx b/src/main/frontend/src/components/CreateLoanDialog.tsx index 51e1bd1..e4254be 100644 --- a/src/main/frontend/src/components/CreateLoanDialog.tsx +++ b/src/main/frontend/src/components/CreateLoanDialog.tsx @@ -79,6 +79,8 @@ function CreateLoanDialog() { }); }, []); + const [calendarDialogOpen, setCalendarDialogOpen] = useState(false); + return ( @@ -208,6 +210,7 @@ function CreateLoanDialog() { "w-[240px] pl-3 text-left font-normal", !field.value && "text-muted-foreground" )} + onClick={() => setCalendarDialogOpen(!calendarDialogOpen)} > {field.value ? ( format(field.value, "PPP") @@ -222,7 +225,10 @@ function CreateLoanDialog() { { + field.onChange(date); + setCalendarDialogOpen(false); + }} disabled={(date) => date > new Date() || date < new Date("1900-01-01") }