From 6f747baaa0df7b3e505b60b178e08b9d976eacf3 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Fri, 1 Jul 2016 17:39:52 +0100 Subject: [PATCH] Fix `deleteIfNewAndEmpty()` being called after annotation was destroyed Listen for the BEFORE_ANNOTATION_CREATED event on the 's own scope which is destroyed when the component itself is destroyed, rather than the root scope which lives for the lifetime of the application. --- h/static/scripts/directive/annotation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h/static/scripts/directive/annotation.js b/h/static/scripts/directive/annotation.js index 78b63ed82a5..6a7027bb299 100644 --- a/h/static/scripts/directive/annotation.js +++ b/h/static/scripts/directive/annotation.js @@ -124,7 +124,7 @@ function AnnotationController( // When a new annotation is created, remove any existing annotations that // are empty - $rootScope.$on(events.BEFORE_ANNOTATION_CREATED, deleteIfNewAndEmpty); + $scope.$on(events.BEFORE_ANNOTATION_CREATED, deleteIfNewAndEmpty); // Call `onGroupFocused()` whenever the currently-focused group changes. $scope.$on(events.GROUP_FOCUSED, onGroupFocused);