fix sidebar doesn't remember resizing between closing to taskbar and reopening

This commit is contained in:
pa
2026-01-08 19:10:40 +09:00
committed by Natsumi
parent 5228252c8e
commit 5cd7e6da5a

View File

@@ -25,14 +25,25 @@ export function useAuthenticatedLayoutResizable() {
const asidePanelRef = ref(null); const asidePanelRef = ref(null);
const navExpandedSize = ref(null); const navExpandedSize = ref(null);
const groupWidth = ref(fallbackWidth); const groupWidth = ref(fallbackWidth);
const draggingCount = ref(0);
let resizeObserver = null; let resizeObserver = null;
const getGroupWidth = () => { const getGroupWidthRaw = () => {
const element = panelGroupRef.value?.$el ?? panelGroupRef.value; const element = panelGroupRef.value?.$el ?? panelGroupRef.value;
const width = element?.getBoundingClientRect?.().width; const width = element?.getBoundingClientRect?.().width;
return Number.isFinite(width) ? width : null;
};
const getGroupWidth = () => {
const width = getGroupWidthRaw();
return Number.isFinite(width) && width > 0 ? width : fallbackWidth; 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 pxToPercent = (px, groupWidth, min = 1) => {
const w = groupWidth ?? getGroupWidth(); const w = groupWidth ?? getGroupWidth();
return Math.min(100, Math.max(min, (px / w) * 100)); return Math.min(100, Math.max(min, (px / w) * 100));
@@ -80,11 +91,16 @@ export function useAuthenticatedLayoutResizable() {
return; return;
} }
const width = getGroupWidth(); if (draggingCount.value === 0) {
if (!Number.isFinite(width) || width <= 0) {
return; return;
} }
const rawWidth = getGroupWidthRaw();
if (!Number.isFinite(rawWidth) || rawWidth <= 0) {
return;
}
const width = rawWidth;
const navSize = sizes[0]; const navSize = sizes[0];
if (!isNavCollapsed.value && Number.isFinite(navSize) && navSize > 0) { if (!isNavCollapsed.value && Number.isFinite(navSize) && navSize > 0) {
navExpandedSize.value = navSize; navExpandedSize.value = navSize;
@@ -183,6 +199,7 @@ export function useAuthenticatedLayoutResizable() {
asideMaxSize, asideMaxSize,
mainDefaultSize, mainDefaultSize,
handleLayout, handleLayout,
setIsDragging,
isAsideCollapsed, isAsideCollapsed,
isNavCollapsed, isNavCollapsed,
isSideBarTabShow isSideBarTabShow