From d8a8af306eb9f1b6c5846f8ae832676b8f8d7215 Mon Sep 17 00:00:00 2001 From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com> Date: Mon, 17 Feb 2020 11:24:35 +0100 Subject: [PATCH] Activating text editing in ngZone.runOutsideAngular to avoid 'refreshing effect' --- .../components/text-editor/text-editor.component.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/cartography/components/text-editor/text-editor.component.ts b/src/app/cartography/components/text-editor/text-editor.component.ts index 0da7c952..39cb032b 100644 --- a/src/app/cartography/components/text-editor/text-editor.component.ts +++ b/src/app/cartography/components/text-editor/text-editor.component.ts @@ -1,4 +1,4 @@ -import { Component, ViewChild, ElementRef, OnInit, Input, EventEmitter, OnDestroy, Renderer2 } from '@angular/core'; +import { Component, ViewChild, ElementRef, OnInit, Input, EventEmitter, OnDestroy, Renderer2, NgZone } from '@angular/core'; import { DrawingsEventSource } from '../../events/drawings-event-source'; import { TextAddedDataEvent, TextEditedDataEvent } from '../../events/event-source'; import { ToolsService } from '../../../services/tools.service'; @@ -55,7 +55,8 @@ export class TextEditorComponent implements OnInit, OnDestroy { private linksDataSource: LinksDataSource, private nodesDataSource: NodesDataSource, private selectionManager: SelectionManager, - private fontFixer: FontFixer + private fontFixer: FontFixer, + private ngZone: NgZone ) {} ngOnInit() { @@ -63,8 +64,8 @@ export class TextEditorComponent implements OnInit, OnDestroy { isActive ? this.activateTextAdding() : this.deactivateTextAdding(); }); - this.activateTextEditingForDrawings(); - this.activateTextEditingForNodeLabels(); + this.ngZone.runOutsideAngular(this.activateTextEditingForDrawings.bind(this)); + this.ngZone.runOutsideAngular(this.activateTextEditingForNodeLabels.bind(this)); } activateTextAdding() {