fix(expandParent: do not mutate change object #4829

This commit is contained in:
moklick
2024-11-24 15:01:28 +01:00
parent 9d26df39ef
commit 7043700192
+10 -6
View File
@@ -148,26 +148,30 @@ const createStore = ({
const changes = []; const changes = [];
for (const [id, dragItem] of nodeDragItems) { for (const [id, dragItem] of nodeDragItems) {
const expandParent = !!(dragItem?.expandParent && dragItem?.parentId && dragItem?.position);
const change: NodeChange = { const change: NodeChange = {
id, id,
type: 'position', type: 'position',
position: dragItem.position, position: expandParent
? {
x: Math.max(0, dragItem.position.x),
y: Math.max(0, dragItem.position.y),
}
: dragItem.position,
dragging, dragging,
}; };
if (dragItem?.expandParent && dragItem?.parentId && change.position) { if (expandParent) {
parentExpandChildren.push({ parentExpandChildren.push({
id, id,
parentId: dragItem.parentId, parentId: dragItem.parentId!,
rect: { rect: {
...dragItem.internals.positionAbsolute, ...dragItem.internals.positionAbsolute,
width: dragItem.measured.width!, width: dragItem.measured.width!,
height: dragItem.measured.height!, 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); changes.push(change);