Skip to content

Commit

Permalink
fix(filter-picker): fix date-range judge error (#1880)
Browse files Browse the repository at this point in the history
Co-authored-by: maxin <maxin@growingio.com>
  • Loading branch information
nnmax and maxin authored Mar 3, 2022
1 parent 314de5d commit fc506e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/legacy/base-picker/BasePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ function BasePicker({
searchBar?.onSearch(current.slice(0, 200).toLocaleLowerCase());
}

const tabs = React.useMemo(() => tabNav?.items?.map((i) => <Tab label={i.children} value={i.key} />), [tabNav]);
const tabs = React.useMemo(
() => tabNav?.items?.map((i) => <Tab label={i.children} value={i.key} key={i.key} />),
[tabNav]
);

const cls = classnames(prefixCls, className);
let content;
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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([
Expand Down

1 comment on commit fc506e1

@vercel
Copy link

@vercel vercel bot commented on fc506e1 Mar 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.