question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing maxlength dynamically of a textarea fires form valueChanges twice after upgrading to Angular 10

See original GitHub issue

🐞 bug report

Affected Package

The issue is caused by package @angular/forms and valueChanges

Is this a regression?

Yes, the previous version in which this bug was not present was: Angular 8

Description

I recently upgraded our application from Angular 8 to Angular 10. After much research, the upgrade was successful. Following the upgrade, I found a bug on form valueChanges with dynamically changing textarea maxlength. I am dynamically changing the maxlength of the textarea based on previous input field in same form. When doing so, form valueChanges gets fired twice and eventually causing Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked error. I have produced a minimal repo below with one textarea and changing it’s maxlength dynamically while typing in it.

πŸ”¬ Minimal Reproduction

https://stackblitz.com/edit/angular-oubtwj Try giving any input to textarea and observe stackblitz console

πŸ”₯ Exception or Error



Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked

🌍 Your Environment

Angular Version: 10.0.3




     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / β–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 10.0.2
Node: 12.12.0
OS: darwin x64

Angular: 10.0.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.2
@angular-devkit/build-angular     0.1000.2
@angular-devkit/build-optimizer   0.1000.2
@angular-devkit/build-webpack     0.1000.2
@angular-devkit/core              10.0.2
@angular-devkit/schematics        10.0.2
@angular/cdk                      10.0.1
@angular/cli                      10.0.2
@angular/material                 10.0.1
@ngtools/webpack                  10.0.2
@nguniversal/builders             10.0.1
@nguniversal/common               10.0.1
@nguniversal/express-engine       10.0.1
@schematics/angular               10.0.2
@schematics/update                0.1000.2
rxjs                              6.6.0
typescript                        3.9.6
webpack                           4.43.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
madhavan-sundararajcommented, Jul 15, 2020

Okay cool. Thank you for your time.

0reactions
angular-automatic-lock-bot[bot]commented, Aug 15, 2020

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reactive forms valueChanges method fires twice for one ...
I have used distinctUntilChanged only, so called valuechanges method called twice time.
Read more >
Reactive Forms - setValue, patchValue And valueChanges
In this demo, I'm trying to store the complete form data in a console window if any control value changes. Here, I am...
Read more >
Angular 10, reactive forms with dynamic rows, validation and ...
Angular 10, reactive forms with dynamic rows, validation and value changes stream. Β· In this example will be described these techniques: Β· 1....
Read more >
Change Log - /inputs - Kendo UI for Angular - Telerik
Learn what changes we have made in our Angular /inputs package. ... deprecate the view option; valueChange fired twice on color selection.
Read more >
Three Ways to Dynamically Alter your Form Validation in ...
We need to listen to optionB value changes and based on that we add or remove the validators we require. We also call...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found