Skip to content

When replacing form control which has async validator the status from statusChange stays PENDING #20424

Closed

Description

@dzonatan

I'm submitting a...

[X] Bug report

Current behavior

When replacing form control with a new one which has asynchronous validator only PENDING status is broadcasted from statusChanges observable.

const myForm = new FormGroup({
  myControl: new FormControl('simple input');
});
    
myForm.statusChanges
  .subscribe(status => console.log(status));

myForm.setControl('myControl', new FormControl('another input', null, asyncValidator));

Console will only print PENDING. Nothing more.

Expected behavior

Final VALID or INVALID status should be broadcasted after async validator finishes his job.

Minimal reproduction of the problem with instructions

https://stackblitz.com/edit/angular-qmdbkx

Please tell us about your environment

Angular version: 7.0.1

Activity

  1. changed the title [-][Forms] When replacing control which has async validator the status from statusChange stays PENDING[/-] [+]When replacing form control which has async validator the status from statusChange stays PENDING[/+] on Nov 15, 2017
  2. added this to the Backlog milestone on Jan 23, 2018
  3. modified the milestones: Backlog, needsTriage on Feb 26, 2018
  4. jsdevtom commented on Jun 11, 2018

    @jsdevtom

    What happens when you listen to the control itself like so:

    myForm.get('myControl').statusChanges
      .subscribe(status => console.log(status));
    
    

    ?

  5. rdnscr commented on Jun 19, 2018

    @rdnscr

    This issue still exists for me in ng v. 6.0.5. I registered myself to the statusChanges event and it is not fired for the result. I only get the notification for the transition to pending.

    In essence this makes it currently quiet hard to use the async validator properly. Are there already some straight forward workarounds?

  6. 5 remaining items

  7. suspectpart commented on Dec 4, 2019

    @suspectpart

    What about this issue? We still have trouble with this behavior. Is a fix anywhere near?

  8. dzonatan commented on Dec 4, 2019

    @dzonatan
    ContributorAuthor

    A fix is waiting to be reviewed/merged at #20806 for two years already.
    Core team simply does not care about issues with forms.
    Same goes with #18575

  9. suspectpart commented on Dec 4, 2019

    @suspectpart

    @kara @jasonaden Since you added labels to this issue: any prospect of having the pull request reviewed and merged eventually?

  10. artoodeeto commented on Dec 10, 2019

    @artoodeeto

    I have the same problem but with addControl so on our form after submitting we are adding a new details on the form, we're creating a new attribute, like after submit we have form.addControl('name', new FormControl('')) but when this is being invoke the async validation from a control will be triggered and the whole form gets a status of pending and invalid @dzonatan same same issue.

  11. self-assigned this
    on Jul 25, 2020
  12. added a commit that references this issue on Sep 5, 2020
    bae9668
  13. angular-automatic-lock-bot commented on Oct 2, 2020

    @angular-automatic-lock-bot

    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.

  14. locked and limited conversation to collaborators on Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions