Skip to content

Commit ac4e7b8

Browse files
committed
Collapse sidebar one breakpoint earlier at xl instead of lg
1 parent 8b2c185 commit ac4e7b8

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

application/shared-webapp/ui/components/Sidebar.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ function SidebarProvider({
128128
if (typeof window === "undefined") {
129129
return persistedOpenRef.current;
130130
}
131-
// On initial load below `lg`, force-collapsed regardless of stored preference.
132-
return window.matchMedia(MEDIA_QUERIES.lg).matches ? persistedOpenRef.current : false;
131+
// On initial load below `xl`, force-collapsed regardless of stored preference.
132+
return window.matchMedia(MEDIA_QUERIES.xl).matches ? persistedOpenRef.current : false;
133133
});
134134
const open = openProp ?? internalOpen;
135135
const setOpen = React.useCallback(
@@ -140,9 +140,9 @@ function SidebarProvider({
140140
} else {
141141
setInternalOpen(openState);
142142
}
143-
// Only persist user choices made at `lg+`. Toggles below `lg` are overlay-mode
143+
// Only persist user choices made at `xl+`. Toggles below `xl` are overlay-mode
144144
// interactions — transient, never written to localStorage.
145-
if (typeof window !== "undefined" && window.matchMedia(MEDIA_QUERIES.lg).matches) {
145+
if (typeof window !== "undefined" && window.matchMedia(MEDIA_QUERIES.xl).matches) {
146146
persistedOpenRef.current = openState;
147147
localStorage.setItem(SIDEBAR_STORAGE_KEY_COLLAPSED, String(!openState));
148148
}
@@ -175,14 +175,14 @@ function SidebarProvider({
175175
return () => window.removeEventListener("keydown", handleKeyDown);
176176
}, [toggleSidebar]);
177177

178-
// Auto-collapse when the viewport drops below `lg`, restore user preference when it grows back.
179-
// Below `lg` the sidebar overlays content (rarely desirable on narrow screens). Transitions
178+
// Auto-collapse when the viewport drops below `xl`, restore user preference when it grows back.
179+
// Below `xl` the sidebar overlays content (rarely desirable on narrow screens). Transitions
180180
// use setInternalOpen directly so they do NOT touch the persisted preference.
181181
React.useEffect(() => {
182182
if (typeof window === "undefined") {
183183
return;
184184
}
185-
const mediaQuery = window.matchMedia(MEDIA_QUERIES.lg);
185+
const mediaQuery = window.matchMedia(MEDIA_QUERIES.xl);
186186
const handleChange = (event: MediaQueryListEvent) => {
187187
setInternalOpen(event.matches ? persistedOpenRef.current : false);
188188
};
@@ -351,28 +351,28 @@ function Sidebar({
351351
data-side={side}
352352
data-slot="sidebar"
353353
>
354-
{/* Backdrop: dims content behind the expanded sidebar in overlay mode (below `lg`).
355-
Hidden at `lg+` where the sidebar pushes content instead of overlaying. Click to collapse.
354+
{/* Backdrop: dims content behind the expanded sidebar in overlay mode (below `xl`).
355+
Hidden at `xl+` where the sidebar pushes content instead of overlaying. Click to collapse.
356356
Starts below any banner strip so banners (which push all top-positioned UI down) stay visible. */}
357357
<button
358358
type="button"
359359
aria-label={t`Close sidebar`}
360360
tabIndex={-1}
361361
onClick={() => setOpen(false)}
362362
className={cn(
363-
"pointer-events-none fixed top-(--banner-offset,0rem) right-0 bottom-0 left-0 z-[35] bg-black/50 opacity-0 transition-opacity duration-100 ease-linear lg:hidden",
363+
"pointer-events-none fixed top-(--banner-offset,0rem) right-0 bottom-0 left-0 z-[35] bg-black/50 opacity-0 transition-opacity duration-100 ease-linear xl:hidden",
364364
"group-data-[state=expanded]:pointer-events-auto group-data-[state=expanded]:opacity-100"
365365
)}
366366
/>
367367
{/* Placeholder width:
368-
- Below `lg`: stays at icon-rail width so the expanded sidebar OVERLAYS content.
369-
- At `lg`+: follows sidebar width so main content pushes right (no overlay).
368+
- Below `xl`: stays at icon-rail width so the expanded sidebar OVERLAYS content.
369+
- At `xl`+: follows sidebar width so main content pushes right (no overlay).
370370
Transitions disabled during drag via `[data-resizing]` on the wrapper. */}
371371
<div
372372
data-slot="sidebar-gap"
373373
className={cn(
374374
"relative w-(--sidebar-width-icon) bg-transparent transition-[width] duration-100 ease-linear",
375-
"lg:w-(--sidebar-width) lg:group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
375+
"xl:w-(--sidebar-width) xl:group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
376376
"group-data-[collapsible=offcanvas]:w-0",
377377
"group-data-[side=right]:rotate-180",
378378
"group-data-[resizing=true]/sidebar-wrapper:transition-none"

0 commit comments

Comments
 (0)