Skip to content

Commit

Permalink
fix(ui): handle resizable panels not rendered in DOM
Browse files Browse the repository at this point in the history
Fixes a bug introduced in a different bug fix in 9c0d357.
  • Loading branch information
psychedelicious committed Sep 25, 2024
1 parent 841178c commit 0d96a1b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion invokeai/frontend/web/src/features/ui/hooks/usePanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const usePanel = (arg: UsePanelOptions): UsePanelReturn => {
arg.panelGroupDirection
);

if (minSizePct > 100) {
if (!minSizePct || minSizePct > 100 || !defaultSizePct || defaultSizePct > 100) {
// This can happen when the panel is hidden
return;
}
Expand Down Expand Up @@ -244,6 +244,11 @@ const getSizeAsPercentage = (
let availableSpace =
panelGroupDirection === 'horizontal' ? panelGroupElement.offsetWidth : panelGroupElement.offsetHeight;

if (!availableSpace) {
// No available space, size is 0
return 0;
}

// ...minus the width/height of the resize handles
getResizeHandleElementsForGroup(id).forEach((el) => {
availableSpace -= panelGroupDirection === 'horizontal' ? el.offsetWidth : el.offsetHeight;
Expand Down

0 comments on commit 0d96a1b

Please # to comment.