fix #797 - clear destroy handler in undomanager

This commit is contained in:
Kevin Jahns
2026-08-04 10:17:09 +02:00
parent 9c1994547d
commit ceae18f4cb

View File

@@ -253,10 +253,9 @@ export class UndoManager extends ObservableV2 {
this.emit('stack-item-updated', changeEvent) this.emit('stack-item-updated', changeEvent)
} }
} }
this.destroy = this.destroy.bind(this)
this.doc.on('afterTransaction', this.afterTransactionHandler) this.doc.on('afterTransaction', this.afterTransactionHandler)
this.doc.on('destroy', () => { this.doc.on('destroy', this.destroy)
this.destroy()
})
} }
/** /**
@@ -383,6 +382,7 @@ export class UndoManager extends ObservableV2 {
destroy () { destroy () {
this.trackedOrigins.delete(this) this.trackedOrigins.delete(this)
this.doc.off('afterTransaction', this.afterTransactionHandler) this.doc.off('afterTransaction', this.afterTransactionHandler)
this.doc.off('destroy', this.destroy)
super.destroy() super.destroy()
} }
} }