mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-29 17:22:25 +01:00
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:
@@ -322,9 +322,11 @@ export function initSidebarLayout(Storage, opts) {
|
||||
syncRailSide();
|
||||
} else if (window.innerWidth >= AUTO_COLLAPSE_WIDTH && isHidden && _wasAutoCollapsed) {
|
||||
// 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.classList.remove('hidden');
|
||||
syncRailSide();
|
||||
void document.body.offsetWidth; // reflow
|
||||
if (chatContainer && chatContainer.offsetWidth < MIN_CHAT_WIDTH) {
|
||||
sidebar.classList.add('hidden');
|
||||
|
||||
Reference in New Issue
Block a user