Skip to content

Commit bbf9bb4

Browse files
committed
FilterBar: fix lint errors
1 parent 7c71bb0 commit bbf9bb4

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import searchIcon from '@ui5/webcomponents-icons/dist/search.js';
77
import { enrichEventWithDetails, useI18nBundle, useStylesheet } from '@ui5/webcomponents-react-base';
88
import { addCustomCSSWithScoping } from '@ui5/webcomponents-react-base/internal/utils';
99
import type { ReactElement, RefObject } from 'react';
10-
import { Children, cloneElement, useEffect, useId, useReducer, useRef, useState } from 'react';
10+
import { Children, cloneElement, useCallback, useEffect, useId, useReducer, useRef, useState } from 'react';
1111
import { FlexBoxDirection } from '../../enums/FlexBoxDirection.js';
1212
import { FlexBoxJustifyContent } from '../../enums/FlexBoxJustifyContent.js';
1313
import { MessageBoxAction } from '../../enums/MessageBoxAction.js';
@@ -200,16 +200,19 @@ export const FilterDialog = (props: FilterDialogPropTypes) => {
200200
}
201201
};
202202

203-
const visibleChildren = () =>
204-
children.filter((item) => {
205-
return !!item?.props && !item?.props?.hidden;
206-
});
203+
const visibleChildren = useCallback(
204+
() =>
205+
children.filter((item) => {
206+
return !!item?.props && !item?.props?.hidden;
207+
}),
208+
[children],
209+
);
207210

208211
useEffect(() => {
209212
if (children.length) {
210213
setOrderedChildren(visibleChildren());
211214
}
212-
}, [children]);
215+
}, [children, visibleChildren]);
213216

214217
const renderChildren = () => {
215218
const searchStringLower = searchString.toLowerCase();
@@ -408,6 +411,8 @@ export const FilterDialog = (props: FilterDialogPropTypes) => {
408411

409412
setForceRequired(undefined);
410413
}
414+
// `forceRequired` triggers async DOM update; no extra deps needed
415+
// eslint-disable-next-line react-hooks/exhaustive-deps
411416
}, [forceRequired]);
412417

413418
const renderGroups = () => {
@@ -450,11 +455,9 @@ export const FilterDialog = (props: FilterDialogPropTypes) => {
450455
});
451456
};
452457

453-
useEffect(() => {
454-
if (initialSelected.current === undefined && selected.length) {
455-
initialSelected.current = selectedFilters;
456-
}
457-
}, [selected]);
458+
if (initialSelected.current === undefined && selected.length) {
459+
initialSelected.current = selectedFilters;
460+
}
458461

459462
return (
460463
<FilterBarDialogContext.Provider

0 commit comments

Comments
 (0)