Skip to content

fix(FilterBar): add workaround for onAfterFiltersDialogOpen #7208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/main/src/components/FilterBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
})();
const [showFilters, setShowFilters] = useState(initiallyShowFilters);
const [dialogOpen, setDialogOpen] = useState(false);
const [delayedDialogOpen, setDelayedDialog] = useState(false);
const dialogRef = useRef<DialogDomRef>(null);
const filterBarButtonsRef = useRef(null);
const filterAreaRef = useRef<HTMLDivElement>(null);
Expand All @@ -118,6 +119,13 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
}
}, [setShowFilters, hideToolbar, filterBarCollapsed]);

//todo: remove state again after https://github.com/SAP/ui5-webcomponents/issues/11281 has been fixed
useEffect(() => {
requestAnimationFrame(() => {
setDelayedDialog(dialogOpen);
});
}, [dialogOpen]);

useStylesheet(styleData, FilterBar.displayName);

const filterAreaClasses = clsx(
Expand Down Expand Up @@ -158,6 +166,7 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
if (typeof onFiltersDialogClose === 'function') {
onFiltersDialogClose(closeTrigger);
}
setDelayedDialog(false);
setDialogOpen(false);
void filterBtnRef.current?.focus();
};
Expand Down Expand Up @@ -409,7 +418,7 @@ const FilterBar = forwardRef<HTMLDivElement, FilterBarPropTypes>((props, ref) =>
</CustomTag>
{dialogOpen && !hideFilterConfiguration && (
<FilterDialog
open={dialogOpen}
open={delayedDialogOpen}
handleDialogClose={handleDialogClose}
handleRestoreFilters={handleRestoreFilters}
showRestoreButton={showResetButton}
Expand Down
Loading