fix lost handle bounds
This commit is contained in:
@@ -25,8 +25,6 @@
|
||||
onnodecontextmenu
|
||||
}: NodeWrapperProps & NodeEvents = $props();
|
||||
|
||||
// $inspect(node);
|
||||
|
||||
let {
|
||||
data = {},
|
||||
selected = false,
|
||||
|
||||
@@ -51,7 +51,7 @@ export type {
|
||||
EdgeTypes,
|
||||
DefaultEdgeOptions
|
||||
} from '$lib/types/edges';
|
||||
export type { HandleProps, FitViewOptions } from '$lib/types/general';
|
||||
export type { HandleProps, FitViewOptions, OnBeforeDelete } from '$lib/types/general';
|
||||
export type { Node, NodeTypes, BuiltInNode, NodeProps, InternalNode } from '$lib/types/nodes';
|
||||
export type { SvelteFlowStore } from '$lib/store/types';
|
||||
export * from '$lib/types/events';
|
||||
|
||||
@@ -87,6 +87,7 @@ export function adoptUserNodes<NodeType extends NodeBase>(
|
||||
options?: UpdateNodesOptions<NodeType>
|
||||
) {
|
||||
const _options = mergeObjects(adoptUserNodesDefaultOptions, options);
|
||||
|
||||
const tmpLookup = new Map(nodeLookup);
|
||||
const selectedNodeZ: number = _options?.elevateNodesOnSelect ? 1000 : 0;
|
||||
|
||||
@@ -345,7 +346,9 @@ export function updateNodeInternals<NodeType extends InternalNodeBase>(
|
||||
},
|
||||
});
|
||||
updatedInternals = true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
const dimensions = getDimensions(update.nodeElement);
|
||||
const dimensionChanged = node.measured.width !== dimensions.width || node.measured.height !== dimensions.height;
|
||||
const doUpdate = !!(
|
||||
@@ -365,7 +368,7 @@ export function updateNodeInternals<NodeType extends InternalNodeBase>(
|
||||
positionAbsolute = clampPosition(positionAbsolute, extent, dimensions);
|
||||
}
|
||||
|
||||
nodeLookup.set(node.id, {
|
||||
const newNode = {
|
||||
...node,
|
||||
measured: dimensions,
|
||||
internals: {
|
||||
@@ -376,10 +379,12 @@ export function updateNodeInternals<NodeType extends InternalNodeBase>(
|
||||
target: getHandleBounds('target', update.nodeElement, nodeBounds, zoom, node.id),
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
nodeLookup.set(node.id, newNode);
|
||||
|
||||
if (node.parentId) {
|
||||
updateChildNode(node, nodeLookup, parentLookup, { nodeOrigin });
|
||||
updateChildNode(newNode, nodeLookup, parentLookup, { nodeOrigin });
|
||||
}
|
||||
|
||||
updatedInternals = true;
|
||||
@@ -395,13 +400,12 @@ export function updateNodeInternals<NodeType extends InternalNodeBase>(
|
||||
parentExpandChildren.push({
|
||||
id: node.id,
|
||||
parentId: node.parentId,
|
||||
rect: nodeToRect(node, nodeOrigin),
|
||||
rect: nodeToRect(newNode, nodeOrigin),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (parentExpandChildren.length > 0) {
|
||||
const parentExpandChanges = handleExpandParent(parentExpandChildren, nodeLookup, parentLookup, nodeOrigin);
|
||||
|
||||
Reference in New Issue
Block a user