From fb234820f800b3529e54d49f081e76a72b9354d8 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Tue, 5 May 2020 17:35:58 +0300 Subject: [PATCH] [Vis Editor] - console error on opening the Inspector from visualization editor Closes: #65268 --- .../public/embeddable/visualize_embeddable.ts | 2 +- .../visualize/public/application/editor/editor.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts b/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts index 8ab144bc03c32..89697ecd7ed71 100644 --- a/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts +++ b/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts @@ -138,7 +138,7 @@ export class VisualizeEmbeddable extends Embeddable inspectorSession.close()); - // Remove that watch in case the user closes the inspector session herself. - inspectorSession.onClose.finally(removeWatch); + + if (inspectorSession) { + // Close the inspector if this scope is destroyed (e.g. because the user navigates away). + const removeWatch = $scope.$on('$destroy', () => inspectorSession.close()); + // Remove that watch in case the user closes the inspector session herself. + inspectorSession.onClose.finally(removeWatch); + } }, tooltip() { if (!embeddableHandler.hasInspector || !embeddableHandler.hasInspector()) {