From eaa1b6f782cdb6ede0f408103ddf95189e41e302 Mon Sep 17 00:00:00 2001 From: SemenStruchev Date: Tue, 21 Nov 2023 15:58:18 +0200 Subject: [PATCH 1/3] set initial values on datepicker outside click --- src/components/DatePicker/DatePickerPopover.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/DatePicker/DatePickerPopover.jsx b/src/components/DatePicker/DatePickerPopover.jsx index 849565d5..50bf5e84 100644 --- a/src/components/DatePicker/DatePickerPopover.jsx +++ b/src/components/DatePicker/DatePickerPopover.jsx @@ -20,6 +20,7 @@ export const DatePickerPopover = ({ getDayContent, ...rest }) => { + const [initialValue] = useState(value); const [originalValue, setOriginalValue] = useState(value); const [isVisible, setIsVisible] = useState(false); @@ -41,8 +42,10 @@ export const DatePickerPopover = ({ onChange?.(value); setIsVisible(false); }; - const handleClickOutside = () => { + if (!value?.to) { + onChange(initialValue); + } toggleVisibility(); }; From 4eae7df11ba9a214926d15b3d3934928f985460e Mon Sep 17 00:00:00 2001 From: SemenStruchev Date: Tue, 21 Nov 2023 16:01:57 +0200 Subject: [PATCH 2/3] fix lint --- src/components/DatePicker/DatePickerPopover.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/DatePicker/DatePickerPopover.jsx b/src/components/DatePicker/DatePickerPopover.jsx index 50bf5e84..06c4c547 100644 --- a/src/components/DatePicker/DatePickerPopover.jsx +++ b/src/components/DatePicker/DatePickerPopover.jsx @@ -42,10 +42,12 @@ export const DatePickerPopover = ({ onChange?.(value); setIsVisible(false); }; + const handleClickOutside = () => { if (!value?.to) { onChange(initialValue); } + toggleVisibility(); }; From e94d5382a2a2c64ea218966b0fa755e3b559dfee Mon Sep 17 00:00:00 2001 From: SemenStruchev Date: Tue, 21 Nov 2023 16:02:56 +0200 Subject: [PATCH 3/3] fix minor issue --- src/components/DatePicker/DatePickerPopover.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/DatePicker/DatePickerPopover.jsx b/src/components/DatePicker/DatePickerPopover.jsx index 06c4c547..0477168f 100644 --- a/src/components/DatePicker/DatePickerPopover.jsx +++ b/src/components/DatePicker/DatePickerPopover.jsx @@ -44,7 +44,7 @@ export const DatePickerPopover = ({ }; const handleClickOutside = () => { - if (!value?.to) { + if (!value?.to && variant === "range") { onChange(initialValue); }