Skip to content

Commit

Permalink
fix(react-utils): fixed useNodeResizing (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
makhnatkin authored Sep 19, 2024
1 parent 2adfe7f commit 4f8977a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/react-utils/useNodeResizing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,16 @@ export const useNodeResizing = ({
setCurrentWidth(newWidth);
setCurrentHeight(newHeight);

// If neither width nor height are provided, the width is set automatically.
const shouldSetWidth =
!initialWidth &&
initialWidth !== 0 &&
!(initialWidth === null && initialHeight === null);
const shouldSetHeight = !initialHeight && initialHeight !== 0;

onResize?.({
width: !initialWidth && initialWidth !== 0 ? undefined : newWidth,
height: !initialHeight && initialHeight !== 0 ? undefined : newHeight,
width: shouldSetWidth ? undefined : newWidth,
height: shouldSetHeight ? undefined : newHeight,
});
}
});
Expand Down

0 comments on commit 4f8977a

Please sign in to comment.