From e10c872efdf5f81a4d03a5c4fc95a2d9ad2beba7 Mon Sep 17 00:00:00 2001 From: SemenStruchev <125129104+SemenStruchev@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:32:18 +0200 Subject: [PATCH] X2-7813 fix range date picker year select (#285) --- src/components/DatePicker/DatePicker.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/DatePicker/DatePicker.jsx b/src/components/DatePicker/DatePicker.jsx index 970d2c740..b809345d7 100644 --- a/src/components/DatePicker/DatePicker.jsx +++ b/src/components/DatePicker/DatePicker.jsx @@ -44,7 +44,9 @@ export const DatePicker = ({ const [currentMonth, setCurrentMonth] = useState(initialValue); const [startMonth, setStartMonth] = useState(value?.from); const [endMonth, setEndMonth] = useState( - dayjs(value?.to).isSame(dayjs(value?.from), "month") ? dayjs(value?.from).add(1, "month").toDate() : value?.to, + dayjs(value?.to).isSame(dayjs(value?.from), "month") + ? dayjs(value?.from).add(1, "month").toDate() + : value?.to ?? dayjs(value?.from).add(1, "month").toDate(), ); const [rangeName, setRangeName] = useState(""); const isRangeVariant = variant === variants.range;