Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

mdc-select does not select the option when set value through form control asynchronously #1638

Closed
@mixth

Description

What Angular MDC version are you using?

0.42.2

What browser(s) is this bug affecting?

Tested on Chrome, Firefox

What OS are you using?

MacOS

What are the steps to reproduce the bug?

  1. Create template with mdc-select with *ngFor options.
  2. Asynchronously assign dynamic options.
  3. Set value of FormControl programmatically (via FormControl::setValue or FormGroup::patchValue).

What is the expected behavior?

mdc-select is selected on the option that has the newly assigned value.

What is the actual behavior?

mdc-select is selected on the first option.

Some reproducible snippet

Template

<div [formGroup]="form">
  <mdc-select formControlName="select">
    <option *ngFor="let number of numbers" [value]="number">{{ number }}</option>
  </mdc-select>
</div>

Controller

form = this.fb.group({
  select: '',
});

numbers = ['1', '2', '3', '4', '5'];

ngOnInit() {
  setTimeout(() => {
    this.numbers = ['6', '7', '8'];
    this.form.controls.select.setValue('7');
  }, 100);
}

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions