From fc506e1cd555c3d8553217ba7fb28a2615a58108 Mon Sep 17 00:00:00 2001 From: maxin <48519459+nnmax@users.noreply.github.com> Date: Thu, 3 Mar 2022 16:03:37 +0800 Subject: [PATCH] fix(filter-picker): fix date-range judge error (#1880) Co-authored-by: maxin --- src/legacy/base-picker/BasePicker.tsx | 5 ++++- .../FilterCondition/components/DateAttrSelect/index.tsx | 6 ++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/legacy/base-picker/BasePicker.tsx b/src/legacy/base-picker/BasePicker.tsx index 931554741c..b0705f9967 100644 --- a/src/legacy/base-picker/BasePicker.tsx +++ b/src/legacy/base-picker/BasePicker.tsx @@ -29,7 +29,10 @@ function BasePicker({ searchBar?.onSearch(current.slice(0, 200).toLocaleLowerCase()); } - const tabs = React.useMemo(() => tabNav?.items?.map((i) => ), [tabNav]); + const tabs = React.useMemo( + () => tabNav?.items?.map((i) => ), + [tabNav] + ); const cls = classnames(prefixCls, className); let content; diff --git a/src/legacy/filter-picker/components/FilterList/Expression/FilterCondition/components/DateAttrSelect/index.tsx b/src/legacy/filter-picker/components/FilterList/Expression/FilterCondition/components/DateAttrSelect/index.tsx index 641cc92d68..399a83b99a 100644 --- a/src/legacy/filter-picker/components/FilterList/Expression/FilterCondition/components/DateAttrSelect/index.tsx +++ b/src/legacy/filter-picker/components/FilterList/Expression/FilterCondition/components/DateAttrSelect/index.tsx @@ -1,7 +1,5 @@ -/* eslint-disable prettier/prettier */ import React, { useEffect, useState } from 'react'; import moment, { Moment } from 'moment'; -import { get, isUndefined } from 'lodash'; import RelativeCurrent from './components/RelativeCurrent'; import RelativeBetween from './components/RelativeBetween'; import IncludeToday from './components/IncludeToday'; @@ -97,8 +95,8 @@ function DateAttrSelect(props: DateAttrSelectProps) { attrChange([v]); }; const dateRangeChange = (value?: [NullableDate, NullableDate]) => { - if (!value || isUndefined(get(value, '[0]') || get(value, '[1]'))) return; - const dateRange = [moment(value?.[0]), moment(value?.[1])]; + if (!value || value.some((item) => !moment(item).isValid())) return; + const dateRange = [moment(value[0]), moment(value[1])]; dateRange && setTimeRange(dateRange); dateRange && attrChange([