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 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