From bba89c3e02a7191fbbd5d92b52af89200f46d80d Mon Sep 17 00:00:00 2001 From: Elastic Jasper Date: Tue, 3 Jan 2017 12:15:09 -0500 Subject: [PATCH] Fix error switching index patterns in Discover Backports PR #9682 **Commit 1:** Fix error switching index patterns in Discover Needed to cleanup debounced function on scope destory. Fixes https://github.com/elastic/kibana/issues/9681 * Original sha: f82624f7cd5bbfe4fdfd222edd6a1f8700d473e9 * Authored by Matthew Bargar on 2016-12-29T22:29:40Z --- src/ui/public/fixed_scroll.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ui/public/fixed_scroll.js b/src/ui/public/fixed_scroll.js index 09963b82870c0..0eda343b37e51 100644 --- a/src/ui/public/fixed_scroll.js +++ b/src/ui/public/fixed_scroll.js @@ -117,11 +117,13 @@ uiModules } } - $scope.$watch(debounce(checkWidth, 100)); + const debouncedCheckWidth = debounce(checkWidth, 100); + $scope.$watch(debouncedCheckWidth); // cleanup when the scope is destroyed $scope.$on('$destroy', function () { cleanUp(); + debouncedCheckWidth.cancel(); $scroller = $window = null; }); }