change(ui): expand the first series on adding a fitler
This commit is contained in:
parent
420cd95858
commit
5226f60834
2 changed files with 9 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import React, {useState} from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import FilterList from 'Shared/Filters/FilterList';
|
||||
import SeriesName from './SeriesName';
|
||||
import cn from 'classnames';
|
||||
|
|
@ -93,6 +93,14 @@ function FilterSeries(props: Props) {
|
|||
} = props;
|
||||
const [expanded, setExpanded] = useState(!expandable);
|
||||
const {series, seriesIndex} = props;
|
||||
const [prevLength, setPrevLength] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (series.filter.filters.length === 1 && prevLength === 0 && seriesIndex === 0) {
|
||||
setExpanded(true);
|
||||
}
|
||||
setPrevLength(series.filter.filters.length);
|
||||
}, [series.filter.filters.length]);
|
||||
|
||||
const onUpdateFilter = (filterIndex: any, filter: any) => {
|
||||
series.filter.updateFilter(filterIndex, filter);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import { metricOf } from 'App/constants/filterOptions';
|
|||
import { AudioWaveform, ChevronDown, ChevronUp, PlusIcon } from 'lucide-react';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import AddStepButton from 'Components/Dashboard/components/FilterSeries/AddStepButton';
|
||||
import { Icon } from 'UI';
|
||||
import FilterItem from 'Shared/Filters/FilterItem';
|
||||
import { FilterKey } from 'Types/filter/filterType';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue