set focus on buttons for alert and confirm

This commit is contained in:
joshuaboud 2021-07-16 11:30:36 -03:00
parent f7753d2a0a
commit 45b20774fd
No known key found for this signature in database
GPG Key ID: 17EFB59E2A8BF50E
1 changed files with 5 additions and 0 deletions

View File

@ -111,6 +111,7 @@ export class ModalPrompt {
this.footer.innerHTML = ""; this.footer.innerHTML = "";
this.footer.appendChild(this.ok); this.footer.appendChild(this.ok);
this.show(); this.show();
this.ok.focus();
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.ok.onclick = () => { this.ok.onclick = () => {
resolve(); resolve();
@ -137,6 +138,10 @@ export class ModalPrompt {
else else
this.yes.classList.add(primary_btn); this.yes.classList.add(primary_btn);
this.show(); this.show();
if (danger)
this.no.focus();
else
this.yes.focus();
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let resolve_true = () => { let resolve_true = () => {
resolve(true); resolve(true);