Skip to content

Commit

Permalink
fix(module:code-editor): re-enter the Angular zone only if the value …
Browse files Browse the repository at this point in the history
…has been changed (#6845)
  • Loading branch information
arturovt authored Jul 12, 2021
1 parent 29d44af commit 5c09948
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions components/code-editor/code-editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ export class NzCodeEditorComponent implements OnDestroy, AfterViewInit {
) as ITextModel;

model.onDidChangeContent(() => {
this.ngZone.run(() => {
this.emitValue(model.getValue());
});
this.emitValue(model.getValue());
});
}

Expand All @@ -285,7 +283,11 @@ export class NzCodeEditorComponent implements OnDestroy, AfterViewInit {
}

this.value = value;
this.onChange(value);
// We're re-entering the Angular zone only if the value has been changed since there's a `return` expression previously.
// This won't cause "dead" change detections (basically when the `tick()` has been run, but there's nothing to update).
this.ngZone.run(() => {
this.onChange(value);
});
}

private updateOptionToMonaco(): void {
Expand Down

0 comments on commit 5c09948

Please sign in to comment.