Prevent close button 'stealing' focus from modal input fields

This commit is contained in:
Michael Shamoon
2021-01-16 14:09:23 -08:00
parent b3004dc690
commit 2b8dcc21cc
6 changed files with 18 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
<form [formGroup]="saveViewConfigForm" (ngSubmit)="save()">
<div class="modal-header">
<h4 class="modal-title" id="modal-basic-title" i18n>Save current view</h4>
<button type="button" class="close" aria-label="Close" (click)="cancel()">
<button type="button" [disabled]="!closeEnabled" class="close" aria-label="Close" (click)="cancel()">
<span aria-hidden="true">&times;</span>
</button>
</div>

View File

@@ -20,6 +20,8 @@ export class SaveViewConfigDialogComponent implements OnInit {
@Input()
buttonsEnabled = true
closeEnabled = false
_defaultName = ""
get defaultName() {
@@ -31,7 +33,7 @@ export class SaveViewConfigDialogComponent implements OnInit {
this._defaultName = value
this.saveViewConfigForm.patchValue({name: value})
}
saveViewConfigForm = new FormGroup({
name: new FormControl(''),
showInSideBar: new FormControl(false),
@@ -39,6 +41,10 @@ export class SaveViewConfigDialogComponent implements OnInit {
})
ngOnInit(): void {
// wait to enable close button so it doesnt steal focus form input
setTimeout(() => {
this.closeEnabled = true
});
}
save() {