fix(node-update): force update when source or target pos changes

This commit is contained in:
moklick
2021-02-23 19:27:45 +01:00
parent 1da1d697b6
commit ebbc192b8d
4 changed files with 19 additions and 10 deletions
+1 -1
View File
@@ -171,7 +171,7 @@ export default (NodeComponent: ComponentType<NodeComponentProps>) => {
useEffect(() => {
if (nodeElement.current && !isHidden) {
updateNodeDimensions([{ id, nodeElement: nodeElement.current }]);
updateNodeDimensions([{ id, nodeElement: nodeElement.current, forceUpdate: true }]);
}
}, [id, isHidden, sourcePosition, targetPosition]);
+4 -4
View File
@@ -78,12 +78,12 @@ export default function reactFlowReducer(state = initialState, action: ReactFlow
const update = action.payload.find((u) => u.id === node.id);
if (update) {
const dimensions = getDimensions(update.nodeElement);
if (
const doUpdate =
dimensions.width &&
dimensions.height &&
(node.__rf.width !== dimensions.width || node.__rf.height !== dimensions.height)
) {
(node.__rf.width !== dimensions.width || node.__rf.height !== dimensions.height || update.forceUpdate);
if (doUpdate) {
const handleBounds = getHandleBounds(update.nodeElement, state.transform[2]);
return {
+1
View File
@@ -370,6 +370,7 @@ export type OnEdgeUpdateFunc<T = any> = (oldEdge: Edge<T>, newConnection: Connec
export type NodeDimensionUpdate = {
id: ElementId;
nodeElement: HTMLDivElement;
forceUpdate?: boolean;
};
export type InitD3ZoomPayload = {