From 5cd7e6da5ae1a4f33a0498af90107badfe10962e Mon Sep 17 00:00:00 2001 From: pa Date: Thu, 8 Jan 2026 19:10:40 +0900 Subject: [PATCH] fix sidebar doesn't remember resizing between closing to taskbar and reopening --- .../useAuthenticatedLayoutResizable.js | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/composables/useAuthenticatedLayoutResizable.js b/src/composables/useAuthenticatedLayoutResizable.js index 8999f273..a2a70bf7 100644 --- a/src/composables/useAuthenticatedLayoutResizable.js +++ b/src/composables/useAuthenticatedLayoutResizable.js @@ -25,14 +25,25 @@ export function useAuthenticatedLayoutResizable() { const asidePanelRef = ref(null); const navExpandedSize = ref(null); const groupWidth = ref(fallbackWidth); + const draggingCount = ref(0); let resizeObserver = null; - const getGroupWidth = () => { + const getGroupWidthRaw = () => { const element = panelGroupRef.value?.$el ?? panelGroupRef.value; const width = element?.getBoundingClientRect?.().width; + return Number.isFinite(width) ? width : null; + }; + + const getGroupWidth = () => { + const width = getGroupWidthRaw(); return Number.isFinite(width) && width > 0 ? width : fallbackWidth; }; + const setIsDragging = (isDragging) => { + const next = draggingCount.value + (isDragging ? 1 : -1); + draggingCount.value = Math.max(0, next); + }; + const pxToPercent = (px, groupWidth, min = 1) => { const w = groupWidth ?? getGroupWidth(); return Math.min(100, Math.max(min, (px / w) * 100)); @@ -80,11 +91,16 @@ export function useAuthenticatedLayoutResizable() { return; } - const width = getGroupWidth(); - if (!Number.isFinite(width) || width <= 0) { + if (draggingCount.value === 0) { return; } + const rawWidth = getGroupWidthRaw(); + if (!Number.isFinite(rawWidth) || rawWidth <= 0) { + return; + } + const width = rawWidth; + const navSize = sizes[0]; if (!isNavCollapsed.value && Number.isFinite(navSize) && navSize > 0) { navExpandedSize.value = navSize; @@ -183,6 +199,7 @@ export function useAuthenticatedLayoutResizable() { asideMaxSize, mainDefaultSize, handleLayout, + setIsDragging, isAsideCollapsed, isNavCollapsed, isSideBarTabShow