From 5a683f9de325a0086e9ece86068baa55d455b060 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Mon, 24 Sep 2018 13:58:35 +0200 Subject: [PATCH] [ML] Fixes Anomaly Explorer resize listener. (#23427) Fixes the cleanup of the resize listener once you change to another page within the ML plugin. --- x-pack/plugins/ml/public/explorer/explorer_controller.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ml/public/explorer/explorer_controller.js b/x-pack/plugins/ml/public/explorer/explorer_controller.js index f7b93edf7b40a6..6b7e7d29adfd62 100644 --- a/x-pack/plugins/ml/public/explorer/explorer_controller.js +++ b/x-pack/plugins/ml/public/explorer/explorer_controller.js @@ -284,13 +284,15 @@ module.controller('MlExplorerController', function ( }); // Redraw the swimlane when the window resizes or the global nav is toggled. - $(window).resize(() => { + function jqueryRedrawOnResize() { + if (resizeTimeout !== null) { $timeout.cancel(resizeTimeout); } // Only redraw 500ms after last resize event. resizeTimeout = $timeout(redrawOnResize, 500); - }); + } + $(window).resize(jqueryRedrawOnResize); const navListener = $scope.$on('globalNav:update', () => { // Run in timeout so that content pane has resized after global nav has updated. @@ -508,6 +510,7 @@ module.controller('MlExplorerController', function ( mlSelectLimitService.state.unwatch(swimlaneLimitListener); delete $scope.cellData; refreshWatcher.cancel(); + $(window).off('resize', jqueryRedrawOnResize); // Cancel listening for updates to the global nav state. navListener(); });