focus first input element in dialogs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { Component, ElementRef, Inject, OnInit, ViewChild } from '@angular/core';
|
||||
import {MatDialog, MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
|
||||
import { DashboardCreationData } from 'src/app/dashboard.service';
|
||||
|
||||
@@ -7,11 +7,18 @@ import { DashboardCreationData } from 'src/app/dashboard.service';
|
||||
templateUrl: './new-dashboard.component.html',
|
||||
styleUrls: ['./new-dashboard.component.scss']
|
||||
})
|
||||
export class NewDashboardComponent {
|
||||
export class NewDashboardComponent implements OnInit {
|
||||
|
||||
@ViewChild('name') nameInput!: ElementRef;
|
||||
|
||||
constructor(public dialogRef: MatDialogRef<NewDashboardComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: DashboardCreationData,){
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
window.setTimeout(() => this.nameInput.nativeElement.focus(), 0);
|
||||
}
|
||||
|
||||
onSaveClick(): void {
|
||||
this.dialogRef.close(this.data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user