Skip to content

IgxCalendar throws "There is no FormControl instance attached to form control element with name ..." when form is recreated #16033

@ddaribo

Description

@ddaribo

Description

Issue is reported in the App Builder - work item 34638.

Can be reproduced in an isolated sample - demo:

<form [formGroup]="formContext" >
  <igx-calendar formControlName="orderDate"></igx-calendar>
   <button type="button" (click)="resetForm()">
      Reset (replace group)
   </button>
</form>
  private createForm() {
    this.formContext = new FormGroup({
      orderDate: new FormControl(new Date()),
    });
  }

  resetForm() {
    this.createForm();
  }

After further investigation, it appears to be a reproduction of this Angular issue and is related to invoking the onChangeCallback from the writeValue method invocation chain.

  • igniteui-angular version: any
  • browser: any

Steps to reproduce

  1. Reset the form in the demo.

Result

ERROR Error: There is no FormControl instance attached to form control element with name: 'orderDate'
    at _throwError (forms.mjs:3532:9)
    at _noControlError (forms.mjs:3528:10)
    at _IgxCalendarComponent.noop4 (forms.mjs:3353:7)
    at _IgxCalendarComponent.selectSingle (igniteui-angular.mjs:52285:12)
    at _IgxCalendarComponent.selectDate (igniteui-angular.mjs:52238:16)
    at set value (igniteui-angular.mjs:52064:10)
    at _IgxCalendarComponent.writeValue (igniteui-angular.mjs:52223:10)
    at setUpControl (forms.mjs:3327:21)
    at forms.mjs:5672:11
    at Array.forEach (<anonymous>)

Expected result

No error

Attachments

Attach a sample if available, and screenshots, if applicable.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions