fix(editor): Fix memory leak in Node Detail View by correctly unsubscribing from event buses (#6021)

This commit is contained in:
OlegIvaniv
2023-04-20 12:26:14 +02:00
committed by GitHub
parent 41660d9e28
commit 0970ec066d
13 changed files with 98 additions and 97 deletions

View File

@@ -121,15 +121,8 @@ export default Vue.extend({
mounted() {
window.addEventListener('keydown', this.onWindowKeydown);
if (this.eventBus) {
this.eventBus.on('close', () => {
this.closeDialog();
});
this.eventBus.on('closeAll', () => {
this.uiStore.closeAllModals();
});
}
this.eventBus?.on('close', this.closeDialog);
this.eventBus?.on('closeAll', this.uiStore.closeAllModals);
const activeElement = document.activeElement as HTMLElement;
if (activeElement) {
@@ -137,6 +130,8 @@ export default Vue.extend({
}
},
beforeDestroy() {
this.eventBus?.off('close', this.closeDialog);
this.eventBus?.off('closeAll', this.uiStore.closeAllModals);
window.removeEventListener('keydown', this.onWindowKeydown);
},
computed: {