Skip to content

Commit

Permalink
fix(scene): fix regression in updateSceneNode for reparenting nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
haweston authored and cshang2017 committed May 7, 2024
1 parent 30c9b1b commit 016e9f5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/scene-composer/src/store/helpers/sceneDocumentHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,20 @@ export const updateSceneNode = (
partial: RecursivePartial<ISceneNodeInternal>,
skipEntityUpdate?: boolean,
): void => {
// cache these values before merge deep overwrites them
const nodeToMove = draft.document.nodeMap[ref];
const oldParentRef = nodeToMove?.parentRef;
const oldParent = draft.document.nodeMap[oldParentRef || ''];

// Ignore childRefs from partial since it's determined by parentRef and handled by this function
const filteredPartial = partial;
delete partial.childRefs;

// update target node
mergeDeep(draft.document.nodeMap[ref], partial);
mergeDeep(draft.document.nodeMap[ref], filteredPartial);

// Reorder logics
if ('parentRef' in partial) {
const nodeToMove = draft.document.nodeMap[ref];
const oldParentRef = nodeToMove?.parentRef;
const oldParent = draft.document.nodeMap[oldParentRef || ''];

const newParentRef = partial.parentRef;

// remove target node from old parent
Expand Down

0 comments on commit 016e9f5

Please sign in to comment.