Skip to content
Snippets Groups Projects
Commit ecebb242 authored by Lukas's avatar Lukas
Browse files

Add onClose prop on new date time picker

parent 747e5745
Branches
Tags
1 merge request!491Lbudginas/#391 new date time picker
...@@ -62,6 +62,10 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({ ...@@ -62,6 +62,10 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({
return true; return true;
}; };
const handleCloseDateTimePicker = () => {
setIsCalendarOpen(false);
};
return ( return (
<Popover <Popover
open={isCalendarOpen} open={isCalendarOpen}
...@@ -91,6 +95,7 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({ ...@@ -91,6 +95,7 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({
value={date} value={date}
onChange={handleSelect} onChange={handleSelect}
open={isCalendarOpen} open={isCalendarOpen}
onClose={handleCloseDateTimePicker}
isValidDate={isValidDate} isValidDate={isValidDate}
/> />
</PopoverContent> </PopoverContent>
......
...@@ -18,6 +18,7 @@ interface CustomDateTimePickerProps { ...@@ -18,6 +18,7 @@ interface CustomDateTimePickerProps {
value: Date; value: Date;
onChange: (date: Date) => void; onChange: (date: Date) => void;
open: boolean; open: boolean;
onClose: () => void;
isValidDate: (day: Date) => boolean; isValidDate: (day: Date) => boolean;
} }
...@@ -42,6 +43,7 @@ const CustomDateTimePicker: React.FC<CustomDateTimePickerProps> = ({ ...@@ -42,6 +43,7 @@ const CustomDateTimePicker: React.FC<CustomDateTimePickerProps> = ({
value, value,
onChange, onChange,
open, open,
onClose,
isValidDate, isValidDate,
}) => { }) => {
const [internalValue, setInternalValue] = useState(value || new Date()); const [internalValue, setInternalValue] = useState(value || new Date());
...@@ -115,6 +117,7 @@ const CustomDateTimePicker: React.FC<CustomDateTimePickerProps> = ({ ...@@ -115,6 +117,7 @@ const CustomDateTimePicker: React.FC<CustomDateTimePickerProps> = ({
const handleConfirm = () => { const handleConfirm = () => {
onChange(internalValue); onChange(internalValue);
setShowYearMonthPicker(false); setShowYearMonthPicker(false);
onClose();
}; };
const renderDays = () => { const renderDays = () => {
...@@ -268,6 +271,7 @@ const CustomDateTimePicker: React.FC<CustomDateTimePickerProps> = ({ ...@@ -268,6 +271,7 @@ const CustomDateTimePicker: React.FC<CustomDateTimePickerProps> = ({
<div className="actions"> <div className="actions">
<button <button
onClick={() => { onClick={() => {
onClose();
setShowYearMonthPicker(false); setShowYearMonthPicker(false);
}} }}
> >
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment