Skip to content

Scheduling infrastructure for absolutely everyone.

Close settings sidebar on window resize (#4662)

Joe Au-Yeungf9ef883f3d82
diff --git a/packages/ui/v2/core/layouts/SettingsLayout.tsx b/packages/ui/v2/core/layouts/SettingsLayout.tsx
index 38f2ad22c61..6c2749cb6c7 100644
--- a/packages/ui/v2/core/layouts/SettingsLayout.tsx
+++ b/packages/ui/v2/core/layouts/SettingsLayout.tsx
@@ -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