Skip to content

Commit 02a82dd

Browse files
Editor: MoveObjectCommand dispatches 'added' event (#21812)
Changing the parent of an object by moving it in the scene hierarchy in the Editor works by calling `parent.remove(child)` and splicing in the child manually to respect the insertion point. Calling `.add()` instead would push the child at the end of the children array. However, without a call to `.add()` there is no dispatch for the `added` event and only a `removed` event is triggered. This PR adds a dispatch for the `added` event so both events are triggered.
1 parent 79fc09b commit 02a82dd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

editor/js/commands/MoveObjectCommand.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class MoveObjectCommand extends Command {
4949
children.splice( this.newIndex, 0, this.object );
5050
this.object.parent = this.newParent;
5151

52+
this.object.dispatchEvent( { type: 'added' } );
5253
this.editor.signals.sceneGraphChanged.dispatch();
5354

5455
}
@@ -61,6 +62,7 @@ class MoveObjectCommand extends Command {
6162
children.splice( this.oldIndex, 0, this.object );
6263
this.object.parent = this.oldParent;
6364

65+
this.object.dispatchEvent( { type: 'added' } );
6466
this.editor.signals.sceneGraphChanged.dispatch();
6567

6668
}

0 commit comments

Comments
 (0)