Skip to content

Commit

Permalink
Fixed Return key not working on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
pklaschka committed Jan 9, 2020
1 parent 7deef63 commit d25632f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/modals/lorem-configuration-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,25 @@ 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');

if (!okButton) {
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:
Expand Down

0 comments on commit d25632f

Please sign in to comment.