Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

deep troubling situation with angular 5 and slow typing into input boxes

Tags:

angular

There is a problem that is posing itself as a show-stopper or deal-breaker. We've completed a web app, using angular 5 & template driven forms where everything works but this one feature is just killing us. It's like a sniper shot.

From time to time, on our laptops and desktops, we experience slow typing into the text fields of our application's input fields. And this happens across the board, ( that is windows, mac, safari, chrome ).

The situation lasts for a while and then it totally goes away! During the happening, there is no indication of anything we can detect (other than the symptom itself ). I mean there are no console log errors, no high CPU activity, no nothing!.

The problem is that we simply observe some delay ( up to a second ) in the appearance of the letters we type in, into the textfields and textrea boxes.

How would you debug this situation?

So far, I have applies the following solutions; spellcheck=no, autocapitalize=off autocomplete=off autocorrect=off But this does not put an end to this saga.

I also compile the app using the "ng build --prod" so it is totally optimized.

Are there any other suggestions you can offer?

Here is how a sample textarea HTML is:

<textarea placeholder="enter text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"  name="description" [(ngModel)]="learningPlan.description"   maxlength="1500" #local_description="ngModel"></textarea>

Is it possible to tell angular to not to do the change detection on these input boxes while typing is going on? I'm running out of options.

There is one possible suggestion in this link whereby someone is suggesting to do this: @Output() event : EventEmitter<any> = new EventEmitter(false); But it does not say where this line of code is supposed to go in.

like image 742
Average Joe Avatar asked Apr 12 '18 04:04

Average Joe


People also ask

How to read input text value in typescript in angular?

For Angular versions,less than 8, viewChild is annoted with ElementRef type in component to read the input value. Finallly, read the input value using ElementRef.nativeElement.value. Controller typescript component on reading input element value on button click. This talks about how to read input text value in typescript.

What is the use of input form in angular?

Form contains multiple html input elements to take input from the user. button allows the user to submit the from to backend API an d it calls click binding event. In Angular, View is html template and controller is an typescript component. Reading input text is basic concept every Angular developer need to know.

Is your angular app slow?

Is your app slow? Learn what to watch out when debugging poor performance in your Angular apps! Angular is, by default, a fast and performant framework. While it leaves ample space for improvement by opting out some of its magic, we almost never have to do anything special to write extremely performant code for the average app.

Do I need to strongly Type MY angular routes?

Some of that data will be mandatory for all the routes, some not. But in any case, it’s useful to strongly type your routes, just like the rest of your codebase. In this article, I’ll quickly go through the base data types of the Angular router, then we’ll explore how to strongly type our Angular routes.


2 Answers

I've found this discussion ionic issue 10837 and i've solved with content on this link.


In my case, this problem was visible when i typed inside a modal. So, my code turned into this:

constructor(public changeDetection: ChangeDetectorRef) {}

openModal() {
    this.changeDetection.detach();
    //open modal
    modal.callback ( r => {
        this.changeDetection.reattach();
    });
}
like image 164
Raphael Stefani Avatar answered Nov 15 '22 03:11

Raphael Stefani


Try to use enableProdMode. You enable it by:

 import {enableProdMode} from '@angular/core';
 :

 enableProdMode();
 platformBrowserDynamic().bootstrapModule(AppModule);
like image 36
Long Field Avatar answered Nov 15 '22 04:11

Long Field