Skip to content

Commit

Permalink
[ML] Fixes Anomaly Explorer resize listener. (#23427)
Browse files Browse the repository at this point in the history
Fixes the cleanup of the resize listener once you change to another page within the ML plugin.
  • Loading branch information
walterra authored Sep 24, 2018
1 parent 8a76a99 commit 55d5500
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions x-pack/plugins/ml/public/explorer/explorer_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
});
Expand Down

0 comments on commit 55d5500

Please sign in to comment.