From 05b1682d1582df3e10bff084676408faa6aec9de Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 8 Jul 2025 11:25:12 +1000 Subject: [PATCH] fix(ui): handle collapsed panels when rehydrating their state --- .../src/features/ui/layouts/navigation-api.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/invokeai/frontend/web/src/features/ui/layouts/navigation-api.ts b/invokeai/frontend/web/src/features/ui/layouts/navigation-api.ts index 322872c3c1..4e01bf7b1b 100644 --- a/invokeai/frontend/web/src/features/ui/layouts/navigation-api.ts +++ b/invokeai/frontend/web/src/features/ui/layouts/navigation-api.ts @@ -147,6 +147,23 @@ export class NavigationApi { } log.debug({ storedState }, 'Found stored state for panel, restoring'); + // If the panel's dimensions are 0, we assume it was collapsed by the user. But when panels are initialzed, + // by default they may have a minimize dimension greater than 0. If we attempt to set a size of 0, it will + // not work - dockview will instead set the size to the minimum size. + // + // The user-facing issue is that the panel will not remember if it was collapsed or not, and will always + // be expanded when navigating to the tab. + // + // To fix this, if we find a stored state with dimensions of 0, we set the constraints to 0 before setting the + // size. + if (storedState.dimensions.width === 0) { + panel.api.setConstraints({ minimumWidth: 0, maximumWidth: 0 }); + } + + if (storedState.dimensions.height === 0) { + panel.api.setConstraints({ minimumHeight: 0, maximumHeight: 0 }); + } + panel.api.setSize(storedState.dimensions); } const { dispose } = panel.api.onDidDimensionsChange(