Skip to content

Commit 4f8977a

Browse files
authored
fix(react-utils): fixed useNodeResizing (#372)
1 parent 2adfe7f commit 4f8977a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/react-utils/useNodeResizing.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,16 @@ export const useNodeResizing = ({
8383
setCurrentWidth(newWidth);
8484
setCurrentHeight(newHeight);
8585

86+
// If neither width nor height are provided, the width is set automatically.
87+
const shouldSetWidth =
88+
!initialWidth &&
89+
initialWidth !== 0 &&
90+
!(initialWidth === null && initialHeight === null);
91+
const shouldSetHeight = !initialHeight && initialHeight !== 0;
92+
8693
onResize?.({
87-
width: !initialWidth && initialWidth !== 0 ? undefined : newWidth,
88-
height: !initialHeight && initialHeight !== 0 ? undefined : newHeight,
94+
width: shouldSetWidth ? undefined : newWidth,
95+
height: shouldSetHeight ? undefined : newHeight,
8996
});
9097
}
9198
});

0 commit comments

Comments
 (0)