Merge pull request #27997 from backstage/catalog-layout-rerender-small-screen

Catalog: fix CatalogFilterLayout.Filters unmounting children
This commit is contained in:
Vincenzo Scamporlino
2024-12-10 10:24:59 +01:00
committed by GitHub
2 changed files with 9 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-react': patch
---
Fixed an issue where `<CatalogFilterLayout.Filters />` would re-render its children on page load for smaller screens, potentially leading to unnecessary additional backend requests.
@@ -34,8 +34,10 @@ export const Filters = (props: {
drawerAnchor?: 'left' | 'right' | 'top' | 'bottom';
};
}) => {
const isScreenSmallerThanBreakpoint = useMediaQuery((theme: Theme) =>
theme.breakpoints.down(props.options?.drawerBreakpoint ?? 'md'),
const isScreenSmallerThanBreakpoint = useMediaQuery(
(theme: Theme) =>
theme.breakpoints.down(props.options?.drawerBreakpoint ?? 'md'),
{ noSsr: true },
);
const theme = useTheme();
const [filterDrawerOpen, setFilterDrawerOpen] = useState<boolean>(false);