Fixed enter in modal confirmation dialogs

This commit is contained in:
Taloth Saldono 2020-09-23 00:12:42 +02:00
parent 482e2d5d42
commit 930742ae2c
2 changed files with 7 additions and 5 deletions

View File

@ -30,10 +30,10 @@ function ConfirmModal(props) {
useEffect(() => { useEffect(() => {
if (isOpen) { if (isOpen) {
bindShortcut('enter', onConfirm); bindShortcut('enter', onConfirm);
} else {
unbindShortcut('enter', onConfirm); return () => unbindShortcut('enter', onConfirm);
} }
}, [onConfirm]); }, [isOpen, onConfirm]);
return ( return (
<Modal <Modal

View File

@ -56,8 +56,10 @@ function keyboardShortcuts(WrappedComponent) {
} }
unbindShortcut = (key) => { unbindShortcut = (key) => {
delete this._mousetrapBindings[key]; if (this._mousetrap != null) {
this._mousetrap.unbind(key); delete this._mousetrapBindings[key];
this._mousetrap.unbind(key);
}
} }
unbindAllShortcuts = () => { unbindAllShortcuts = () => {