fix(layouting): update node dimensions closes #1181
This commit is contained in:
@@ -49,7 +49,6 @@ export default (NodeComponent: ComponentType<NodeComponentProps>) => {
|
||||
isDragging,
|
||||
resizeObserver,
|
||||
}: WrapNodeProps) => {
|
||||
const observerInitialized = useRef<boolean>(false);
|
||||
const updateNodeDimensions = useStoreActions((actions) => actions.updateNodeDimensions);
|
||||
const addSelectedElements = useStoreActions((actions) => actions.addSelectedElements);
|
||||
const updateNodePosDiff = useStoreActions((actions) => actions.updateNodePosDiff);
|
||||
@@ -203,16 +202,13 @@ export default (NodeComponent: ComponentType<NodeComponentProps>) => {
|
||||
);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
// the resize observer calls an updateNodeDimensions initially.
|
||||
// We don't need to force another dimension update if it hasn't happened yet
|
||||
if (nodeElement.current && !isHidden && observerInitialized.current) {
|
||||
if (nodeElement.current && !isHidden) {
|
||||
updateNodeDimensions([{ id, nodeElement: nodeElement.current, forceUpdate: true }]);
|
||||
}
|
||||
}, [id, isHidden, sourcePosition, targetPosition]);
|
||||
|
||||
useEffect(() => {
|
||||
if (nodeElement.current) {
|
||||
observerInitialized.current = true;
|
||||
const currNode = nodeElement.current;
|
||||
resizeObserver?.observe(currNode);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user