Skip to content

Commit d85e290

Browse files
committed
Update index.tsx
1 parent e4812f9 commit d85e290

File tree

1 file changed

+11
-13
lines changed
  • packages/main/src/components/FilterBar

1 file changed

+11
-13
lines changed

packages/main/src/components/FilterBar/index.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,11 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
121121

122122
useEffect(() => {
123123
if (filterBarCollapsed !== undefined) {
124+
// syncing controlled prop to state
125+
// eslint-disable-next-line react-hooks/set-state-in-effect
124126
setShowFilters(!hideToolbar ? !filterBarCollapsed : true);
125127
}
126-
}, [setShowFilters, hideToolbar, filterBarCollapsed]);
128+
}, [hideToolbar, filterBarCollapsed]);
127129

128130
useStylesheet(styleData, FilterBar.displayName);
129131

@@ -207,6 +209,8 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
207209
}
208210
};
209211

212+
const calculatedChildren = renderChildren();
213+
210214
const handleFBRestore = () => {
211215
handleRestoreFilters({
212216
source: 'filterBar',
@@ -288,7 +292,7 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
288292
useEffect(() => {
289293
const debouncedObserverFn = debounce(([area]: ResizeObserverEntry[]) => {
290294
const firstChild = area.target?.children?.[0] as HTMLDivElement;
291-
if (firstChild && firstChild.offsetWidth !== firstChildWidth) {
295+
if (firstChild) {
292296
setFirstChildWidth(firstChild.offsetWidth + 16 /*margin*/);
293297
}
294298
}, 100);
@@ -300,14 +304,12 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
300304
debouncedObserverFn.cancel();
301305
filterAreaObserver.disconnect();
302306
};
303-
}, [filterAreaRef.current, hideToolbar]);
307+
}, [hideToolbar]);
304308

305309
useEffect(() => {
306310
const debouncedObserverFn = debounce(([area]: ResizeObserverEntry[]) => {
307311
const filterWidth = resizeObserverEntryWidth(area);
308-
if (filterWidth !== filterBarButtonsWidth) {
309-
setFilterAreaWidth(filterWidth);
310-
}
312+
setFilterAreaWidth(filterWidth);
311313
}, 100);
312314
const filterAreaObserver = new ResizeObserver(debouncedObserverFn);
313315
if (hideToolbar && filterAreaRef.current) {
@@ -317,14 +319,12 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
317319
debouncedObserverFn.cancel();
318320
filterAreaObserver.disconnect();
319321
};
320-
}, [filterAreaWidth, filterAreaRef.current, hideToolbar]);
322+
}, [hideToolbar]);
321323

322324
useEffect(() => {
323325
const debouncedObserverFn = debounce(([buttons]: ResizeObserverEntry[]) => {
324326
const buttonsWidth = resizeObserverEntryWidth(buttons);
325-
if (buttonsWidth !== filterBarButtonsWidth) {
326-
setFilterBarButtonsWidth(buttonsWidth);
327-
}
327+
setFilterBarButtonsWidth(buttonsWidth);
328328
}, 100);
329329
const filterBarButtonsObserver = new ResizeObserver(debouncedObserverFn);
330330
if (hideToolbar && filterBarButtonsRef.current) {
@@ -334,9 +334,7 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
334334
debouncedObserverFn.cancel();
335335
filterBarButtonsObserver.disconnect();
336336
};
337-
}, [filterBarButtonsRef.current, hideToolbar, filterBarButtonsWidth]);
338-
339-
const calculatedChildren = renderChildren();
337+
}, [hideToolbar]);
340338

341339
// calculates the number of spacers depending on the available width inside the row
342340
const renderSpacers = () => {

0 commit comments

Comments
 (0)