From ecebb2421edbe0cd52b0396a0dd2fc21589f4290 Mon Sep 17 00:00:00 2001 From: Lukas <lukas.budginas@gmail.com> Date: Thu, 5 Dec 2024 17:41:06 +0200 Subject: [PATCH] Add onClose prop on new date time picker --- components/DateTimePicker.tsx | 5 +++++ components/customDateTime/CustomDateTImePicker.tsx | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/components/DateTimePicker.tsx b/components/DateTimePicker.tsx index 811ae9da..7bde6bb2 100644 --- a/components/DateTimePicker.tsx +++ b/components/DateTimePicker.tsx @@ -62,6 +62,10 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({ return true; }; + const handleCloseDateTimePicker = () => { + setIsCalendarOpen(false); + }; + return ( <Popover open={isCalendarOpen} @@ -91,6 +95,7 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({ value={date} onChange={handleSelect} open={isCalendarOpen} + onClose={handleCloseDateTimePicker} isValidDate={isValidDate} /> </PopoverContent> diff --git a/components/customDateTime/CustomDateTImePicker.tsx b/components/customDateTime/CustomDateTImePicker.tsx index 0c9db625..fa4de958 100644 --- a/components/customDateTime/CustomDateTImePicker.tsx +++ b/components/customDateTime/CustomDateTImePicker.tsx @@ -18,6 +18,7 @@ interface CustomDateTimePickerProps { value: Date; onChange: (date: Date) => void; open: boolean; + onClose: () => void; isValidDate: (day: Date) => boolean; } @@ -42,6 +43,7 @@ const CustomDateTimePicker: React.FC<CustomDateTimePickerProps> = ({ value, onChange, open, + onClose, isValidDate, }) => { const [internalValue, setInternalValue] = useState(value || new Date()); @@ -115,6 +117,7 @@ const CustomDateTimePicker: React.FC<CustomDateTimePickerProps> = ({ const handleConfirm = () => { onChange(internalValue); setShowYearMonthPicker(false); + onClose(); }; const renderDays = () => { @@ -268,6 +271,7 @@ const CustomDateTimePicker: React.FC<CustomDateTimePickerProps> = ({ <div className="actions"> <button onClick={() => { + onClose(); setShowYearMonthPicker(false); }} > -- GitLab