From a57d6227d246c82839b3e10ab75835f1233ff86f Mon Sep 17 00:00:00 2001 From: Mossroy Date: Wed, 1 Jun 2022 12:08:34 +0200 Subject: [PATCH] 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 --- www/js/lib/uiUtil.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/www/js/lib/uiUtil.js b/www/js/lib/uiUtil.js index 9262f88f..927c8e38 100644 --- a/www/js/lib/uiUtil.js +++ b/www/js/lib/uiUtil.js @@ -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(); + } + } + }); }); }