mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 04:42:03 +08:00
fix: [GH-4451]: custom time range modal closed on focussing closed date (#4456)
* fix: [GH-4451]: custom time range modal closed on focussing closed date * fix: jest test
This commit is contained in:
parent
0200fb3a21
commit
01fc7a7fd4
@ -12,6 +12,7 @@ describe('CustomDateTimeModal', () => {
|
||||
visible
|
||||
onCreate={handleCreate}
|
||||
onCancel={handleCancel}
|
||||
setCustomDTPickerVisible={jest.fn()}
|
||||
/>,
|
||||
);
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { DatePicker, Modal } from 'antd';
|
||||
import dayjs, { Dayjs } from 'dayjs';
|
||||
import { useState } from 'react';
|
||||
import { Dispatch, SetStateAction, useState } from 'react';
|
||||
|
||||
export type DateTimeRangeType = [Dayjs | null, Dayjs | null] | null;
|
||||
|
||||
@ -10,12 +10,12 @@ function CustomDateTimeModal({
|
||||
visible,
|
||||
onCreate,
|
||||
onCancel,
|
||||
setCustomDTPickerVisible,
|
||||
}: CustomDateTimeModalProps): JSX.Element {
|
||||
const [selectedDate, setDateTime] = useState<DateTimeRangeType>();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const onModalOkHandler = (date_time: any): void => {
|
||||
onCreate(date_time);
|
||||
setDateTime(date_time);
|
||||
};
|
||||
|
||||
@ -25,7 +25,10 @@ function CustomDateTimeModal({
|
||||
};
|
||||
|
||||
const onOk = (): void => {
|
||||
if (selectedDate) onCreate(selectedDate);
|
||||
if (selectedDate) {
|
||||
onCreate(selectedDate);
|
||||
setCustomDTPickerVisible(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@ -42,7 +45,6 @@ function CustomDateTimeModal({
|
||||
allowClear
|
||||
onOk={onModalOkHandler}
|
||||
showTime
|
||||
onCalendarChange={onModalOkHandler}
|
||||
/>
|
||||
</Modal>
|
||||
);
|
||||
@ -52,6 +54,7 @@ interface CustomDateTimeModalProps {
|
||||
visible: boolean;
|
||||
onCreate: (dateTimeRange: DateTimeRangeType) => void;
|
||||
onCancel: () => void;
|
||||
setCustomDTPickerVisible: Dispatch<SetStateAction<boolean>>;
|
||||
}
|
||||
|
||||
export default CustomDateTimeModal;
|
||||
|
@ -216,7 +216,6 @@ function DateTimeSelection({
|
||||
if (dateTimeRange !== null) {
|
||||
const [startTimeMoment, endTimeMoment] = dateTimeRange;
|
||||
if (startTimeMoment && endTimeMoment) {
|
||||
setCustomDTPickerVisible(false);
|
||||
updateTimeInterval('custom', [
|
||||
startTimeMoment?.toDate().getTime() || 0,
|
||||
endTimeMoment?.toDate().getTime() || 0,
|
||||
@ -352,6 +351,7 @@ function DateTimeSelection({
|
||||
onCancel={(): void => {
|
||||
setCustomDTPickerVisible(false);
|
||||
}}
|
||||
setCustomDTPickerVisible={setCustomDTPickerVisible}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user