Skip to content

Commit 895cb86

Browse files
fix(ui): fix panel resize bug
A bug that caused panels to be collapsed on a fresh indexedDb in was fixed in dd32c63, but this re-introduced a different bug that caused the panels to expand on window resize, if they were already collapsed. Revert the previous change and instead add one imperative resize outside the observer, so that on startup, we set both panels to their minimum sizes.
1 parent fe5bceb commit 895cb86

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

invokeai/frontend/web/src/features/ui/hooks/usePanel.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,26 @@ export const usePanel = (arg: UsePanelOptions): UsePanelReturn => {
125125

126126
_setMinSize(minSizePct);
127127

128-
// Resize if the current size is smaller than the new min size - happens when the window is resized smaller
129-
if (panelHandleRef.current.getSize() < minSizePct) {
128+
const currentSize = panelHandleRef.current.getSize();
129+
130+
// If currentSize is 0, the panel is collapsed, so we don't want to resize it
131+
// If it's not 0, but less than the minSize, resize it
132+
if (currentSize && currentSize < minSizePct) {
130133
panelHandleRef.current.resize(minSizePct);
131134
}
132135
});
133136

134137
resizeObserver.observe(panelGroupElement);
135138
panelGroupHandleElements.forEach((el) => resizeObserver.observe(el));
136139

140+
// Resize the panel to the min size once on startup
141+
const minSizePct = getSizeAsPercentage(
142+
arg.minSize,
143+
arg.panelGroupRef,
144+
arg.panelGroupDirection
145+
);
146+
panelHandleRef.current?.resize(minSizePct);
147+
137148
return () => {
138149
resizeObserver.disconnect();
139150
};

0 commit comments

Comments
 (0)