From: Ricardo Marques Date: Thu, 12 Apr 2018 00:44:09 +0000 (+0100) Subject: mgr/dashboard: Force focus on submit X-Git-Tag: v13.1.0~208^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=617632b358194bcc6da51f3c799727a00ac44d7a;p=ceph.git mgr/dashboard: Force focus on submit Forcing focus on submit button will guarantee that all inputs will lose focus before submission. Signed-off-by: Ricardo Marques --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/submit-button/submit-button.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/submit-button/submit-button.component.ts index c9b0ac41645d7..3cc35df4d7bb5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/submit-button/submit-button.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/submit-button/submit-button.component.ts @@ -45,6 +45,8 @@ export class SubmitButtonComponent implements OnInit { } submit() { + this.focusButton(); + if (this.form.invalid) { this.focusInvalid(); return; @@ -54,6 +56,12 @@ export class SubmitButtonComponent implements OnInit { this.submitAction.emit(); } + focusButton() { + this.elRef.nativeElement.offsetParent.querySelector( + 'button[type="submit"]' + ).focus(); + } + focusInvalid() { const target = this.elRef.nativeElement.offsetParent.querySelector( 'input.ng-invalid, select.ng-invalid'