fix(react): dont allow invalid selection rect

This commit is contained in:
moklick
2024-05-02 18:02:38 +02:00
parent ec2592966e
commit ad3a803abb
3 changed files with 17 additions and 19 deletions
@@ -5,7 +5,7 @@
import { useRef, useEffect, type MouseEvent, type KeyboardEvent } from 'react';
import cc from 'classcat';
import { shallow } from 'zustand/shallow';
import { getInternalNodesBounds } from '@xyflow/system';
import { getInternalNodesBounds, isNumeric } from '@xyflow/system';
import { useStore, useStoreApi } from '../../hooks/useStore';
import { useDrag } from '../../hooks/useDrag';
@@ -26,8 +26,8 @@ const selector = (s: ReactFlowState) => {
});
return {
width,
height,
width: isNumeric(width) ? width : null,
height: isNumeric(height) ? height : null,
userSelectionActive: s.userSelectionActive,
transformString: `translate(${s.transform[0]}px,${s.transform[1]}px) scale(${s.transform[2]}) translate(${x}px,${y}px)`,
};