From d25632f561fc971669f7764555a810c221a705bb Mon Sep 17 00:00:00 2001 From: Pablo Klaschka Date: Thu, 9 Jan 2020 21:51:11 +0100 Subject: [PATCH] Fixed Return key not working on macOS --- src/modals/lorem-configuration-modal.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/modals/lorem-configuration-modal.js b/src/modals/lorem-configuration-modal.js index 1c5c242..165649b 100644 --- a/src/modals/lorem-configuration-modal.js +++ b/src/modals/lorem-configuration-modal.js @@ -121,8 +121,8 @@ async function modalAsync() { width: 18px; }`, onBeforeShow: - htmlDialogElement => { - htmlDialogElement.appendChild(document.createElement('header')); + (dialogElement, elements, actions) => { + dialogElement.appendChild(document.createElement('header')); const okButton = document.getElementById('lorem-main-dialogHelperBtnOk'); @@ -130,6 +130,16 @@ async function modalAsync() { throw new Error('Ok button was not found and could therefore not get selected!'); } + // Temporary fix for enter key not working on macOS: + okButton.addEventListener('keydown', evt => { + if (evt.key === 'Enter') { + evt.stopPropagation(); + evt.preventDefault(); + + actions.close(); + } + }); + okButton.setAttribute('autofocus', 'autofocus'); // For Racing condition bug on Windows: