1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Angular Material Autocomplete Input Refocusing After MatDialog Closes

Discussão em 'Angular' iniciado por DELVIN N J, Julho 24, 2025.

  1. DELVIN N J

    DELVIN N J Guest

    The issue I'm encountering is that after the MatDialog closes, the autocomplete input field automatically regains focus. This is not the desired behavior. I'd like to prevent this automatic refocusing.

    HTML

    <input #myAutocompleteInput type="text" formControlName="myField"
    [matAutocomplete]="myAuto" (optionSelected)="handleOptionSelection()">
    <mat-autocomplete #myAuto="matAutocomplete">
    </mat-autocomplete>


    Typescript

    handleOptionSelection(): void {
    const dialogRef = this.dialog.open(AlertComponent, {
    width: '650px',
    height: '450px',
    });

    dialogRef.afterClosed().subscribe(result => {
    if (result) {
    this.ticketPDFGeneratorService.generateReportFromRow(rec.id.trim(), rec.no);
    this.requestFormGroup.patchValue({ clinic: '' });
    }
    });
    }

    Continue reading...

Compartilhe esta Página