Skip to content

Commit

Permalink
Bug fix: About dialog not dismissed when pressing ESC
Browse files Browse the repository at this point in the history
  • Loading branch information
aecreations committed Mar 6, 2022
1 parent c70e2ab commit cc51344
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions wx-src/pages/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ document.addEventListener("click", aEvent => {
window.addEventListener("keydown", aEvent => {
if (aEvent.key == "Enter" && aeDialog.isOpen()) {
aeDialog.acceptDlgs();

// Don't trigger any further actions that would have occurred if the
// ENTER key was pressed.
aEvent.preventDefault();
}
else if (aEvent.key == "Escape" && aeDialog.isOpen()) {
aeDialog.cancelDlgs();
Expand Down
14 changes: 11 additions & 3 deletions wx-src/scripts/aeDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class aeDialog

static acceptDlgs()
{
let openDlgElts = document.querySelectorAll(".lightbox-show");
let openDlgElts = document.querySelectorAll(".lightbox.lightbox-show");

if (openDlgElts.length > 0) {
// Normally there should just be 1 dialog open at a time.
Expand All @@ -112,11 +112,19 @@ class aeDialog

static cancelDlgs()
{
let openDlgElts = document.querySelectorAll(".lightbox-show");
let openDlgElts = document.querySelectorAll(".lightbox.lightbox-show");

if (openDlgElts.length > 0) {
// Normally there should just be 1 dialog open at a time.
let cancelBtns = document.querySelectorAll(".lightbox-show .dlg-cancel:not(:disabled)");
cancelBtns.forEach(aBtn => { aBtn.click() });
if (cancelBtns.length > 0) {
cancelBtns.forEach(aBtn => { aBtn.click() });
}
else {
// Dialog only has an OK, Close or Done button.
let acceptBtns = document.querySelectorAll(".lightbox-show .dlg-accept");
acceptBtns.forEach(aBtn => { aBtn.click() });
}
}
}
}

0 comments on commit cc51344

Please sign in to comment.