From 945b815fe09450d3905597c17357a984b9181cdd Mon Sep 17 00:00:00 2001 From: Andrej Ocenas Date: Wed, 16 Oct 2019 12:54:13 +0200 Subject: [PATCH] Fix: Unsubscribe from events in dashboards (#19788) * Unsubscribe on unmount * Fix unsubscribe --- public/app/features/dashboard/dashgrid/PanelChrome.tsx | 2 ++ .../app/features/dashboard/panel_editor/VisualizationTab.tsx | 3 +++ 2 files changed, 5 insertions(+) diff --git a/public/app/features/dashboard/dashgrid/PanelChrome.tsx b/public/app/features/dashboard/dashgrid/PanelChrome.tsx index 65294d95258..450cddb8fc3 100644 --- a/public/app/features/dashboard/dashgrid/PanelChrome.tsx +++ b/public/app/features/dashboard/dashgrid/PanelChrome.tsx @@ -81,6 +81,8 @@ export class PanelChrome extends PureComponent { componentWillUnmount() { this.props.panel.events.off(PanelEvents.refresh, this.onRefresh); + this.props.panel.events.off(PanelEvents.render, this.onRender); + if (this.querySubscription) { this.querySubscription.unsubscribe(); this.querySubscription = null; diff --git a/public/app/features/dashboard/panel_editor/VisualizationTab.tsx b/public/app/features/dashboard/panel_editor/VisualizationTab.tsx index 470df708e0c..3b9bca2d48d 100644 --- a/public/app/features/dashboard/panel_editor/VisualizationTab.tsx +++ b/public/app/features/dashboard/panel_editor/VisualizationTab.tsx @@ -151,6 +151,9 @@ export class VisualizationTab extends PureComponent { } componentWillUnmount() { + if (this.querySubscription) { + this.querySubscription.unsubscribe(); + } this.cleanUpAngularOptions(); }