Handle Enter key in Bootstrap modal dialogs (#864)

* Handle Enter key in Bootstrap modal dialogs

Fixes #863

* Switch to native DOM methods, and keyup event
This commit is contained in:
Mossroy 2022-06-01 12:08:34 +02:00 committed by GitHub
parent 70273d71fe
commit a57d6227d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,6 +73,18 @@ define(rqDef, function(settingsStore) {
resolve(false);
}
});
document.getElementById('alertModal').addEventListener('keyup', function (e) {
if (/Enter/.test(e.key)){
// We need to focus before clicking the button, because the handler above is based on document.activeElement
if (isConfirm) {
document.getElementById('approveConfirm').focus();
document.getElementById('approveConfirm').click();
} else {
document.getElementById('closeMessage').focus();
document.getElementById('closeMessage').click();
}
}
});
});
}