Skip to content

Commit

Permalink
Fixed enter in modal confirmation dialogs
Browse files Browse the repository at this point in the history
(cherry picked from commit 930742ae2c69a530afe60f76a5824f2722540df8)
  • Loading branch information
Taloth authored and ta264 committed Sep 27, 2020
1 parent 4a19a01 commit 769164a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions frontend/src/Components/Modal/ConfirmModal.js
Expand Up @@ -30,10 +30,10 @@ function ConfirmModal(props) {
useEffect(() => {
if (isOpen) {
bindShortcut('enter', onConfirm);
} else {
unbindShortcut('enter', onConfirm);

return () => unbindShortcut('enter', onConfirm);
}
}, [onConfirm]);
}, [isOpen, onConfirm]);

return (
<Modal
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/Components/keyboardShortcuts.js
Expand Up @@ -56,8 +56,10 @@ function keyboardShortcuts(WrappedComponent) {
}

unbindShortcut = (key) => {
delete this._mousetrapBindings[key];
this._mousetrap.unbind(key);
if (this._mousetrap != null) {
delete this._mousetrapBindings[key];
this._mousetrap.unbind(key);
}
}

unbindAllShortcuts = () => {
Expand Down

0 comments on commit 769164a

Please sign in to comment.