fix(ui): handle resizable panels not rendered in DOM

Fixes a bug introduced in a different bug fix in 9c0d357817.
This commit is contained in:
psychedelicious
2024-09-26 06:06:45 +10:00
parent 841178ceb7
commit 0fccd9936c

View File

@@ -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;
}
@@ -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;