From 4ddf4a22a37aa1d91fa69f0d2349e66052a21f77 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 20 Mar 2020 08:37:35 -0700 Subject: [PATCH] Fixed: Enter on Delete profile confirmation deleting all unused profiles --- frontend/src/Components/Modal/ConfirmModal.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/Components/Modal/ConfirmModal.js b/frontend/src/Components/Modal/ConfirmModal.js index 529a5d973..bd80ce7b8 100644 --- a/frontend/src/Components/Modal/ConfirmModal.js +++ b/frontend/src/Components/Modal/ConfirmModal.js @@ -23,11 +23,16 @@ function ConfirmModal(props) { isSpinning, onConfirm, onCancel, - bindShortcut + bindShortcut, + unbindShortcut } = props; useEffect(() => { - bindShortcut('enter', onConfirm); + if (isOpen) { + bindShortcut('enter', onConfirm); + } else { + unbindShortcut('enter', onConfirm); + } }, [onConfirm]); return ( @@ -81,7 +86,8 @@ ConfirmModal.propTypes = { isSpinning: PropTypes.bool.isRequired, onConfirm: PropTypes.func.isRequired, onCancel: PropTypes.func.isRequired, - bindShortcut: PropTypes.func.isRequired + bindShortcut: PropTypes.func.isRequired, + unbindShortcut: PropTypes.func.isRequired }; ConfirmModal.defaultProps = {