Skip to content

Commit

Permalink
Fix deleteIfNewAndEmpty() being called after annotation was destroyed
Browse files Browse the repository at this point in the history
Listen for the BEFORE_ANNOTATION_CREATED event on the <annotation>'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.
  • Loading branch information
robertknight committed Jul 1, 2016
1 parent 1cadf90 commit 6f747ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion h/static/scripts/directive/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6f747ba

Please sign in to comment.