Close settings sidebar on window resize (#4662)

pull/4705/head^2
Joe Au-Yeung 2022-09-26 15:09:51 -04:00 committed by GitHub
parent 9ddbaf0966
commit f9ef883f3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -296,6 +296,20 @@ export default function SettingsLayout({
}: { children: React.ReactNode } & ComponentProps<typeof Shell>) {
const state = useState(false);
const [sideContainerOpen, setSideContainerOpen] = state;
useEffect(() => {
const closeSideContainer = () => {
if (window.innerWidth >= 1024) {
setSideContainerOpen(false);
}
};
window.addEventListener("resize", closeSideContainer);
return () => {
window.removeEventListener("resize", closeSideContainer);
};
}, []);
return (
<Shell
flexChildrenContainer