Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove focus from mat-select after selection change

In .html file i have selector:

<mat-form-field>
    <mat-select #selector(selectionChange)="onSelectionChange($event.value)">
      <mat-option *ngFor="let test of tests" [value]="test">
      </mat-option>
    </mat-select>
  </mat-form-field>

In .ts file I have:

  @ViewChild('selector', { static: false }) selector: MatSelect

  onSelectionChange(value: any) {
    this.selector.focused = false;
  }

It doesn't work because focused is read only parameter, but how to achieve this effect other way?

like image 683
Iwoo Avatar asked Dec 02 '25 06:12

Iwoo


1 Answers

MatSelect expose close method.

Try this:

 onSelectionChange(value: any) {
    this.selector.close();
  }
like image 153
Chellappan வ Avatar answered Dec 04 '25 06:12

Chellappan வ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!