From f82624f7cd5bbfe4fdfd222edd6a1f8700d473e9 Mon Sep 17 00:00:00 2001 From: Matthew Bargar Date: Thu, 29 Dec 2016 17:29:40 -0500 Subject: [PATCH] Fix error switching index patterns in Discover Needed to cleanup debounced function on scope destory. Fixes https://github.com/elastic/kibana/issues/9681 --- 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; }); }