fix(sidebar): measure the auto-collapse restore with the sidebar at full width

When the window widens after an auto-collapse, the restore check removes
.hidden and measures the chat width to decide whether the sidebar fits.
html.ody-sidebar-mini also forces the sidebar to width 0 and was only
cleared by syncRailSide() after the measurement, so the check always saw
a 0-width sidebar and restored it even when the chat ended up narrower
than MIN_CHAT_WIDTH. Sync the mode classes before measuring.
This commit is contained in:
Yu-Wei Chang
2026-10-24 22:53:45 -07:00
parent 4954cc2e8c
commit 76abce349b
+3 -1
View File
@@ -322,9 +322,11 @@ export function initSidebarLayout(Storage, opts) {
syncRailSide(); syncRailSide();
} else if (window.innerWidth >= AUTO_COLLAPSE_WIDTH && isHidden && _wasAutoCollapsed) { } else if (window.innerWidth >= AUTO_COLLAPSE_WIDTH && isHidden && _wasAutoCollapsed) {
// Only restore if chat won't be too narrow. Suppress the width // Only restore if chat won't be too narrow. Suppress the width
// transition so the reflow measures the sidebar at its full width. // transition and sync the mode classes (ody-sidebar-mini also forces
// width 0) so the reflow measures the sidebar at its full width.
sidebar.style.transition = 'none'; sidebar.style.transition = 'none';
sidebar.classList.remove('hidden'); sidebar.classList.remove('hidden');
syncRailSide();
void document.body.offsetWidth; // reflow void document.body.offsetWidth; // reflow
if (chatContainer && chatContainer.offsetWidth < MIN_CHAT_WIDTH) { if (chatContainer && chatContainer.offsetWidth < MIN_CHAT_WIDTH) {
sidebar.classList.add('hidden'); sidebar.classList.add('hidden');