Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): fix panel resize bug #5407

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions invokeai/frontend/web/src/features/ui/hooks/usePanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,26 @@ export const usePanel = (arg: UsePanelOptions): UsePanelReturn => {

_setMinSize(minSizePct);

// Resize if the current size is smaller than the new min size - happens when the window is resized smaller
if (panelHandleRef.current.getSize() < minSizePct) {
const currentSize = panelHandleRef.current.getSize();

// If currentSize is 0, the panel is collapsed, so we don't want to resize it
// If it's not 0, but less than the minSize, resize it
if (currentSize > 0 && currentSize < minSizePct) {
panelHandleRef.current.resize(minSizePct);
}
});

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

// Resize the panel to the min size once on startup
const minSizePct = getSizeAsPercentage(
arg.minSize,
arg.panelGroupRef,
arg.panelGroupDirection
);
panelHandleRef.current?.resize(minSizePct);

return () => {
resizeObserver.disconnect();
};
Expand Down