Merge pull request #4846 from xyflow/fix/redux-immer-expand-parent
Fix/redux immer expand parent
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@xyflow/react': patch
|
||||
---
|
||||
|
||||
Make it possible to use expandParent with immer and other immutable helpers
|
||||
@@ -148,26 +148,30 @@ const createStore = ({
|
||||
const changes = [];
|
||||
|
||||
for (const [id, dragItem] of nodeDragItems) {
|
||||
const expandParent = !!(dragItem?.expandParent && dragItem?.parentId && dragItem?.position);
|
||||
|
||||
const change: NodeChange = {
|
||||
id,
|
||||
type: 'position',
|
||||
position: dragItem.position,
|
||||
position: expandParent
|
||||
? {
|
||||
x: Math.max(0, dragItem.position.x),
|
||||
y: Math.max(0, dragItem.position.y),
|
||||
}
|
||||
: dragItem.position,
|
||||
dragging,
|
||||
};
|
||||
|
||||
if (dragItem?.expandParent && dragItem?.parentId && change.position) {
|
||||
if (expandParent) {
|
||||
parentExpandChildren.push({
|
||||
id,
|
||||
parentId: dragItem.parentId,
|
||||
parentId: dragItem.parentId!,
|
||||
rect: {
|
||||
...dragItem.internals.positionAbsolute,
|
||||
width: dragItem.measured.width!,
|
||||
height: dragItem.measured.height!,
|
||||
},
|
||||
});
|
||||
|
||||
change.position.x = Math.max(0, change.position.x);
|
||||
change.position.y = Math.max(0, change.position.y);
|
||||
}
|
||||
|
||||
changes.push(change);
|
||||
|
||||
Reference in New Issue
Block a user