From 7c44ae5e3a6aea7e50f10303ce53bf9d79b830e9 Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Fri, 3 Jun 2022 08:33:28 +0100 Subject: [PATCH] Add keyboard handling to System Alert Former-commit-id: a9c8966ca096385e9f61141817f812854d26fb72 [formerly 285cd265dca65028c3bcefd6e393cbbf2c1c316e [formerly 26e90368a2413894c762c0fa788ae5b489df18ab]] Former-commit-id: fc3d5d47a0b747590d5dbc56eafb9f601b8cda70 [formerly 51a483a7a6f53b236f2ceec03ed180d71c44a4da] Former-commit-id: 642183c6ea27a5ba9d8f2992b67e0aad205e5eda --- 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 8258406a..6e58c00f 100644 --- a/www/js/lib/uiUtil.js +++ b/www/js/lib/uiUtil.js @@ -656,6 +656,18 @@ define(rqDef, function(util) { 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(); + } + } + }); }); }