From 928e31b5488b1aff4a87d31c48c70aab1565a36b Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 23 Sep 2015 17:22:32 -0700 Subject: [PATCH] [Common UI] Avoid apply-in-a-digest Don't invoke from mct-resize when first observing an element's size during linking; observed issue in the context of adding domain selector to time conductor. --- platform/commonUI/general/src/directives/MCTResize.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/commonUI/general/src/directives/MCTResize.js b/platform/commonUI/general/src/directives/MCTResize.js index 7f2d722803..f0fd8e0a69 100644 --- a/platform/commonUI/general/src/directives/MCTResize.js +++ b/platform/commonUI/general/src/directives/MCTResize.js @@ -58,6 +58,7 @@ define( // Link; start listening for changes to an element's size function link(scope, element, attrs) { var lastBounds, + linking = true, active = true; // Determine how long to wait before the next update @@ -74,7 +75,9 @@ define( lastBounds.width !== bounds.width || lastBounds.height !== bounds.height) { scope.$eval(attrs.mctResize, { bounds: bounds }); - scope.$apply(); // Trigger a digest + if (!linking) { // Avoid apply-in-a-digest + scope.$apply(); + } lastBounds = bounds; } } @@ -101,6 +104,9 @@ define( // Handle the initial callback onInterval(); + + // Trigger scope.$apply on subsequent changes + linking = false; } return {