Unverified Commit 76034ad1 authored by Torkel Ödegaard's avatar Torkel Ödegaard Committed by GitHub
Browse files

Annotations: Fixing recursive angular watch loop (#33090)

parent 58380368
......@@ -30,7 +30,9 @@ export class AngularEditorLoader extends React.PureComponent<Props> {
}
if (this.angularComponent && prevProps.annotation !== this.props.annotation) {
this.angularComponent.getScope().ctrl.currentAnnotation = this.props.annotation;
const scope = this.angularComponent.getScope();
scope.ctrl.ignoreNextWatcherFiring = true;
scope.ctrl.currentAnnotation = this.props.annotation;
}
}
......@@ -45,12 +47,19 @@ export class AngularEditorLoader extends React.PureComponent<Props> {
ctrl: {
currentDatasource: this.props.datasource,
currentAnnotation: this.props.annotation,
ignoreNextWatcherFiring: false,
},
};
this.angularComponent = loader.load(this.ref, scopeProps, template);
this.angularComponent.digest();
this.angularComponent.getScope().$watch(() => {
// To avoid recursive loop when the annotation is updated from outside angular in componentDidUpdate
if (scopeProps.ctrl.ignoreNextWatcherFiring) {
scopeProps.ctrl.ignoreNextWatcherFiring = false;
return;
}
this.props.onChange({
...scopeProps.ctrl.currentAnnotation,
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment