Skip to content

Commit 5727165

Browse files
authored
fix(FilterBar): after opening the filters-dialog, enable manual control of filters again (#683)
1 parent 0ce8778 commit 5727165

File tree

1 file changed

+21
-1
lines changed
  • packages/main/src/components/FilterBar

1 file changed

+21
-1
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ const FilterBar: FC<FilterBarPropTypes> = forwardRef((props: FilterBarPropTypes,
228228
return Children.toArray(children) as unknown[];
229229
}, [toggledFilters, children]);
230230

231+
const prevChildren = useRef({});
232+
231233
const renderChildren = useCallback(() => {
232234
const childProps = { considerGroupName, inFB: true } as any;
233235
return safeChildren()
@@ -252,10 +254,28 @@ const FilterBar: FC<FilterBarPropTypes> = forwardRef((props: FilterBarPropTypes,
252254
filterItemProps = filterValue(dialogItemRef, child);
253255
}
254256
}
255-
if (!child.props.children)
257+
if (!child.props.children) {
256258
return cloneElement(child as ReactElement<any>, {
257259
...childProps
258260
});
261+
}
262+
if (
263+
prevChildren.current?.[child.key] &&
264+
//Input
265+
(child.props.children?.props?.value !== prevChildren.current?.[child.key]?.value ||
266+
//Combobox
267+
child.props.children?.props?.filterValue !== prevChildren.current?.[child.key]?.filterValue ||
268+
//Checkbox
269+
child.props.children?.props?.checked !== prevChildren.current?.[child.key]?.checked ||
270+
//Selectable
271+
child.props.children?.props?.children?.map((item) => item.props.selected).join(',') !==
272+
prevChildren?.current?.[child.key]?.children?.map((item) => item.props.selected).join(','))
273+
) {
274+
const { [child.key]: omit, ...rest } = dialogRefs;
275+
setDialogRefs(rest);
276+
}
277+
prevChildren.current[child.key] = child.props.children.props;
278+
259279
return cloneElement(child as ReactElement<any>, {
260280
...childProps,
261281
children: {

0 commit comments

Comments
 (0)