fix(core): should trigger parent transform change after node disposed (#440)

This commit is contained in:
Louis Young 2025-07-02 12:01:40 +08:00 committed by GitHub
parent 867ceb8bc2
commit d8e2b4a838
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -458,8 +458,14 @@ export class TransformData extends EntityData<TransformSchema> implements Transf
private _parentChangedDispose?: DisposableCollection; private _parentChangedDispose?: DisposableCollection;
private entityDispose?: Disposable;
setParent(parent: TransformData | undefined, listenParentData = true): void { setParent(parent: TransformData | undefined, listenParentData = true): void {
if (this._parent !== parent) { if (this._parent !== parent) {
if (this.entityDispose) {
this.entityDispose.dispose();
this.entityDispose = undefined;
}
if (this._parentChangedDispose) { if (this._parentChangedDispose) {
this._parentChangedDispose.dispose(); this._parentChangedDispose.dispose();
this._parentChangedDispose = undefined; this._parentChangedDispose = undefined;
@ -470,6 +476,9 @@ export class TransformData extends EntityData<TransformSchema> implements Transf
parent._children.push(this); parent._children.push(this);
this._parentChangedDispose = new DisposableCollection(); this._parentChangedDispose = new DisposableCollection();
this.toDispose.push(this._parentChangedDispose); this.toDispose.push(this._parentChangedDispose);
this.entityDispose = this.entity.onDispose(() => {
parent.fireChange();
});
this._parentChangedDispose.pushAll([ this._parentChangedDispose.pushAll([
parent.onDispose(() => { parent.onDispose(() => {
this.setParent(undefined); this.setParent(undefined);
@ -478,7 +487,6 @@ export class TransformData extends EntityData<TransformSchema> implements Transf
const index = parent._children!.indexOf(this); const index = parent._children!.indexOf(this);
if (index !== -1) { if (index !== -1) {
parent._children!.splice(index, 1); parent._children!.splice(index, 1);
parent.fireChange();
} }
}), }),
]); ]);