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