mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-15 09:33:52 -07:00
Only bind shortcut for pending changes confirmation when it's shown
(cherry picked from commit ded7c3c6e2459f041297d479c788febc5d061854)
This commit is contained in:
parent
ba90095a47
commit
c3eda6ff12
1 changed files with 10 additions and 4 deletions
|
@ -14,12 +14,17 @@ function PendingChangesModal(props) {
|
||||||
isOpen,
|
isOpen,
|
||||||
onConfirm,
|
onConfirm,
|
||||||
onCancel,
|
onCancel,
|
||||||
bindShortcut
|
bindShortcut,
|
||||||
|
unbindShortcut
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (isOpen) {
|
||||||
bindShortcut('enter', onConfirm);
|
bindShortcut('enter', onConfirm);
|
||||||
}, [bindShortcut, onConfirm]);
|
|
||||||
|
return () => unbindShortcut('enter', onConfirm);
|
||||||
|
}
|
||||||
|
}, [bindShortcut, unbindShortcut, isOpen, onConfirm]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
@ -60,7 +65,8 @@ PendingChangesModal.propTypes = {
|
||||||
kind: PropTypes.oneOf(kinds.all),
|
kind: PropTypes.oneOf(kinds.all),
|
||||||
onConfirm: PropTypes.func.isRequired,
|
onConfirm: PropTypes.func.isRequired,
|
||||||
onCancel: PropTypes.func.isRequired,
|
onCancel: PropTypes.func.isRequired,
|
||||||
bindShortcut: PropTypes.func.isRequired
|
bindShortcut: PropTypes.func.isRequired,
|
||||||
|
unbindShortcut: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
PendingChangesModal.defaultProps = {
|
PendingChangesModal.defaultProps = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue