From eb80a333cf8e9ab34d4d77f56d328cd648d4ca7a Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sun, 4 Jun 2017 22:49:46 -0400 Subject: [PATCH] Don't rely on modalSelection to indicate modal is visible The modal can be dismissed other ways (Esc, click 'X', etc) --- modules/ui/shortcuts.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/ui/shortcuts.js b/modules/ui/shortcuts.js index c5ef9a8db..62902dfe4 100644 --- a/modules/ui/shortcuts.js +++ b/modules/ui/shortcuts.js @@ -18,22 +18,25 @@ export function uiShortcuts() { var keybinding = d3keybinding('shortcuts') .on(['?', '⇧/'], function () { - if (modalSelection) { - modalSelection.close(); - modalSelection = null; - return; + if (d3.selectAll('.modal-shortcuts').size()) { // already showing + if (modalSelection) { + modalSelection.close(); + modalSelection = null; + } + } else { + modalSelection = uiModal(savedSelection); + shortcutsModal(modalSelection); } - modalSelection = uiModal(savedSelection); - shortcutsModal(modalSelection); }); d3.select(document) .call(keybinding); + function shortcutsModal(modalSelection) { modalSelection.select('.modal') - .attr('class', 'modal modal-shortcuts fillL col6'); + .classed('modal-shortcuts', true); var shortcutsModal = modalSelection.select('.content'); @@ -169,7 +172,6 @@ export function uiShortcuts() { shortcutKeys .selectAll('kbd.shortcut') .data(function (d) { - var arr; if (detected.os === 'win' && d.text === 'shortcuts.editing.commands.redo') { return [{ shortcut: 'Y',