Skip to content

Commit

Permalink
Handle Enter key in Bootstrap modal dialogs (#864)
Browse files Browse the repository at this point in the history
* Handle Enter key in Bootstrap modal dialogs

Fixes #863

* Switch to native DOM methods, and keyup event
  • Loading branch information
mossroy authored Jun 1, 2022
1 parent 70273d7 commit a57d622
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions www/js/lib/uiUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
});
});
}

Expand Down

0 comments on commit a57d622

Please sign in to comment.