components icon indicating copy to clipboard operation
components copied to clipboard

new FormControls with Validation pushed to a FormArray are always shown as invalid

Open ChrisWun opened this issue 6 years ago • 3 comments

Reproduction

https://stackblitz.com/edit/angular-material-5qkpvd

Steps to reproduce:

  1. click on "Add"

Expected Behavior

The new Field should not be shown as invalid. Other Fields of the FormArray should not be validated.

Actual Behavior

The new field is displayed as Invalid. All fields of the FormArray that are invalid are shown as invalid, although they are still untouched.

Environment

  • Angular: 8.2.2
  • CDK/Material: 8.2.2
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS

ChrisWun avatar Feb 26 '20 12:02 ChrisWun

The problem is that the add button doesn't have a type, which means that the browser will default it to submit, causing it to submit the form every time you click it. You can resolve it by adding type="button".

crisbeto avatar Feb 26 '20 12:02 crisbeto

Sorry for the inconvenience and thank you very much for the answer! :)

I missed that...

ChrisWun avatar Mar 02 '20 13:03 ChrisWun

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.