fix(layout): start the sidebar on the icon rail at tablet widths

A 256 px expanded sidebar next to a 768 px viewport leaves the content
a 512 px column — an iPad held upright rendered every page squeezed.
With no stored preference, md–lg widths now start collapsed to the
icon rail; a manual toggle persists and wins on every later visit.
This commit is contained in:
Marc-André Bombeck committed 2026-07-04 15:51:46 +02:00
1 parent a9e554a083
commit ed5cadf25d
1 file changed
+11 -1
+11 -1
View File
@@ -255,7 +255,17 @@ export function SidebarNav() {
const [collapsed, setCollapsed] = useState(() => {
if (typeof window === "undefined") return false;
try {
return localStorage.getItem(STORAGE_KEY) === "true";
const stored = localStorage.getItem(STORAGE_KEY);
if (stored !== null) return stored === "true";
} catch {
return false;
}
// No stored preference: tablet widths (md–lg, e.g. an iPad held
// upright) start on the icon rail so the content column keeps its
// room — a 256 px sidebar squeezes a 768 px viewport down to 512 px.
// A manual toggle persists and wins on every later visit.
try {
return window.matchMedia("(max-width: 1023.98px)").matches;
} catch {
return false;
}