@bitrise/bitkit 13.10.1-alpha.0 → 13.10.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { Modal, ModalOverlay, useMultiStyleConfig } from '@chakra-ui/react';
|
|
3
3
|
import { isEqual } from '../../utils/utils';
|
|
4
4
|
import Box, { BoxProps } from '../Box/Box';
|
|
@@ -46,8 +46,6 @@ const Filter = (props: FilterProps) => {
|
|
|
46
46
|
...rest
|
|
47
47
|
} = props;
|
|
48
48
|
|
|
49
|
-
const initialState = useRef<FilterState>();
|
|
50
|
-
|
|
51
49
|
const filterStyle = useMultiStyleConfig('Filter') as FilterStyle;
|
|
52
50
|
|
|
53
51
|
const cleanState: FilterState = {};
|
|
@@ -61,6 +59,8 @@ const Filter = (props: FilterProps) => {
|
|
|
61
59
|
}
|
|
62
60
|
});
|
|
63
61
|
|
|
62
|
+
const initialState = useRef<FilterState>(cleanState);
|
|
63
|
+
|
|
64
64
|
const [isPopoverOpen, setPopoverOpen] = useState<boolean>(false);
|
|
65
65
|
|
|
66
66
|
const deleteFromState = (category: string, stateProp: FilterState): FilterState => {
|
|
@@ -112,7 +112,7 @@ const Filter = (props: FilterProps) => {
|
|
|
112
112
|
filters[value.type || 'tag'][category] = value;
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
const showClearFilters =
|
|
115
|
+
const showClearFilters = !isEqual(initialState.current, state);
|
|
116
116
|
|
|
117
117
|
const contextValue: FilterContextType = useMemo(
|
|
118
118
|
() => ({
|
|
@@ -127,12 +127,6 @@ const Filter = (props: FilterProps) => {
|
|
|
127
127
|
[data, filtersDependOn, isLoading, onFilterChange, onFilterClear, setPopoverOpen, cleanState],
|
|
128
128
|
);
|
|
129
129
|
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
if (!initialState.current) {
|
|
132
|
-
initialState.current = cleanState;
|
|
133
|
-
}
|
|
134
|
-
}, []);
|
|
135
|
-
|
|
136
130
|
return (
|
|
137
131
|
<FilterContext value={contextValue}>
|
|
138
132
|
<Box sx={filterStyle.container} {...rest}>
|
|
@@ -36,7 +36,7 @@ const FilterSearch = (props: FilterSearchProps) => {
|
|
|
36
36
|
onChange('search', searchValue.length ? [searchValue] : []);
|
|
37
37
|
}, 500);
|
|
38
38
|
return () => clearTimeout(delayInputTimeoutId);
|
|
39
|
-
}, [searchValue
|
|
39
|
+
}, [searchValue]);
|
|
40
40
|
|
|
41
41
|
useEffect(() => {
|
|
42
42
|
setSearchValue(value);
|