From c4cc03542d1ef125b15440ea0be762e494cf07fd Mon Sep 17 00:00:00 2001 From: ahmadshaheer Date: Thu, 19 Dec 2024 20:01:21 +0430 Subject: [PATCH] fix: fix the stale value issue in range picker --- .../src/components/CustomTimePicker/RangePickerModal.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/CustomTimePicker/RangePickerModal.tsx b/frontend/src/components/CustomTimePicker/RangePickerModal.tsx index 0866bf0179..188fc5837b 100644 --- a/frontend/src/components/CustomTimePicker/RangePickerModal.tsx +++ b/frontend/src/components/CustomTimePicker/RangePickerModal.tsx @@ -55,12 +55,12 @@ function RangePickerModal(props: RangePickerModalProps): JSX.Element { }; const { timezone } = useTimezone(); - const defaultValue = useMemo( - (): [Dayjs, Dayjs] => [ + const rangeValue: [Dayjs, Dayjs] = useMemo( + () => [ dayjs(minTime / 1000_000).tz(timezone.value), dayjs(maxTime / 1000_000).tz(timezone.value), ], - [minTime, maxTime, timezone.value], + [maxTime, minTime, timezone.value], ); return ( @@ -78,7 +78,7 @@ function RangePickerModal(props: RangePickerModalProps): JSX.Element { onOk={onModalOkHandler} // eslint-disable-next-line react/jsx-props-no-spreading {...(selectedTime === 'custom' && { - defaultValue, + value: rangeValue, })} />