From 6d3b74c38ced1346d865fc378cf84dd00c0f60a1 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed <68777211+huzaifa-99@users.noreply.github.com> Date: Fri, 5 May 2023 05:10:12 +0500 Subject: [PATCH 01/10] Block navigation shortcuts when plaid modal is loading --- src/CONST.js | 16 +++++++++ src/components/AddPlaidBankAccount.js | 48 ++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/CONST.js b/src/CONST.js index 1ad76fae5636..b4379a4c1e55 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -23,6 +23,9 @@ const keyInputEnter = lodashGet(KeyCommand, 'constants.keyInputEnter', 'keyInput const keyInputUpArrow = lodashGet(KeyCommand, 'constants.keyInputUpArrow', 'keyInputUpArrow'); const keyInputDownArrow = lodashGet(KeyCommand, 'constants.keyInputDownArrow', 'keyInputDownArrow'); +// describes if a shortcut key can cause navigation +const KEYBOARD_SHORTCUT_NAVIGATION_TYPE = 'NAVIGATION_SHORTCUT' + const CONST = { ANDROID_PACKAGE_NAME, ANIMATED_TRANSITION: 300, @@ -254,6 +257,7 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: 'k', modifierFlags: keyModifierCommand}, [PLATFORM_IOS]: {input: 'k', modifierFlags: keyModifierCommand}, }, + type: KEYBOARD_SHORTCUT_NAVIGATION_TYPE, }, NEW_GROUP: { descriptionKey: 'newGroup', @@ -264,6 +268,7 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: 'k', modifierFlags: keyModifierShiftCommand}, [PLATFORM_IOS]: {input: 'k', modifierFlags: keyModifierShiftCommand}, }, + type: KEYBOARD_SHORTCUT_NAVIGATION_TYPE, }, SHORTCUT_MODAL: { descriptionKey: 'openShortcutDialog', @@ -274,6 +279,7 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: 'j', modifierFlags: keyModifierCommand}, [PLATFORM_IOS]: {input: 'j', modifierFlags: keyModifierCommand}, }, + type: '', }, ESCAPE: { descriptionKey: 'escape', @@ -284,6 +290,7 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: keyInputEscape}, [PLATFORM_IOS]: {input: keyInputEscape}, }, + type: '', }, ENTER: { descriptionKey: null, @@ -294,6 +301,7 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: keyInputEnter}, [PLATFORM_IOS]: {input: keyInputEnter}, }, + type: '', }, CTRL_ENTER: { descriptionKey: null, @@ -304,6 +312,7 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: keyInputEnter, modifierFlags: keyModifierCommand}, [PLATFORM_IOS]: {input: keyInputEnter, modifierFlags: keyModifierCommand}, }, + type: '', }, COPY: { descriptionKey: 'copy', @@ -314,6 +323,7 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: 'c', modifierFlags: keyModifierCommand}, [PLATFORM_IOS]: {input: 'c', modifierFlags: keyModifierCommand}, }, + type: '', }, ARROW_UP: { descriptionKey: null, @@ -324,6 +334,7 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: keyInputUpArrow}, [PLATFORM_IOS]: {input: keyInputUpArrow}, }, + type: '', }, ARROW_DOWN: { descriptionKey: null, @@ -334,13 +345,18 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: keyInputDownArrow}, [PLATFORM_IOS]: {input: keyInputDownArrow}, }, + type: '', }, TAB: { descriptionKey: null, shortcutKey: 'Tab', modifiers: [], + type: '', }, }, + KEYBOARD_SHORTCUTS_TYPES: { + NAVIGATION_SHORTCUT: KEYBOARD_SHORTCUT_NAVIGATION_TYPE, + }, KEYBOARD_SHORTCUT_KEY_DISPLAY_NAME: { CONTROL: 'CTRL', ESCAPE: 'ESC', diff --git a/src/components/AddPlaidBankAccount.js b/src/components/AddPlaidBankAccount.js index 1977795e2301..77ca9a604237 100644 --- a/src/components/AddPlaidBankAccount.js +++ b/src/components/AddPlaidBankAccount.js @@ -22,6 +22,8 @@ import getBankIcon from './Icon/BankIcons'; import Icon from './Icon'; import FullPageOfflineBlockingView from './BlockingViews/FullPageOfflineBlockingView'; import {withNetwork} from './OnyxProvider'; +import CONST from '../CONST'; +import KeyboardShortcut from '../libs/KeyboardShortcut'; const propTypes = { /** Contains plaid data */ @@ -74,6 +76,7 @@ class AddPlaidBankAccount extends React.Component { super(props); this.getPlaidLinkToken = this.getPlaidLinkToken.bind(this); + this.subscribedKeyboardShortcuts = [] } componentDidMount() { @@ -86,6 +89,13 @@ class AddPlaidBankAccount extends React.Component { } componentDidUpdate(prevProps) { + // block keyboard shortcuts that can navigate when plaid modal is shown + if (lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0) { + this.unblockKeyboardShortcuts() + } else { + this.blockKeyboardShortcuts() + } + if (!prevProps.network.isOffline || this.props.network.isOffline || this.isAuthenticatedWithPlaid()) { return; } @@ -94,6 +104,42 @@ class AddPlaidBankAccount extends React.Component { BankAccounts.openPlaidBankLogin(this.props.allowDebit, this.props.bankAccountID); } + componentWillUnmount() { + this.unblockKeyboardShortcuts() + } + + /** + * Blocks the keyboard shortcuts that can navigate + */ + blockKeyboardShortcuts() { + // return early if shortcuts already blocked + if (this.subscribedKeyboardShortcuts.length > 0) return + + // find and block the shortcuts + const shortcutsToBlock = Object.values(CONST.KEYBOARD_SHORTCUTS).filter(x => x.type === CONST.KEYBOARD_SHORTCUTS_TYPES.NAVIGATION_SHORTCUT) + const unsubscribeCallbacks = shortcutsToBlock.map(shortcut => { + return KeyboardShortcut.subscribe( + shortcut.shortcutKey, + () => {}, // do nothing + shortcut.descriptionKey, + shortcut.modifiers, + false, + false, // stop bubbling + ) + }) + this.subscribedKeyboardShortcuts = unsubscribeCallbacks + } + + /** + * Unblocks the keyboard shortcuts that can navigate + */ + unblockKeyboardShortcuts() { + if (this.subscribedKeyboardShortcuts.length > 0) { + _.each(this.subscribedKeyboardShortcuts, unsubscribe => unsubscribe()); + this.subscribedKeyboardShortcuts = [] + } + } + /** * @returns {String} */ @@ -206,4 +252,4 @@ export default compose( initWithStoredValues: false, }, }), -)(AddPlaidBankAccount); +)(AddPlaidBankAccount); \ No newline at end of file From 3d14b7aa941988919ad2a9e706a41c2973dbca82 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed <68777211+huzaifa-99@users.noreply.github.com> Date: Fri, 5 May 2023 06:17:06 +0500 Subject: [PATCH 02/10] Fixed lint issues --- src/CONST.js | 2 +- src/components/AddPlaidBankAccount.js | 77 ++++++++++++++------------- 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index b4379a4c1e55..f1a72b37e0e9 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -24,7 +24,7 @@ const keyInputUpArrow = lodashGet(KeyCommand, 'constants.keyInputUpArrow', 'keyI const keyInputDownArrow = lodashGet(KeyCommand, 'constants.keyInputDownArrow', 'keyInputDownArrow'); // describes if a shortcut key can cause navigation -const KEYBOARD_SHORTCUT_NAVIGATION_TYPE = 'NAVIGATION_SHORTCUT' +const KEYBOARD_SHORTCUT_NAVIGATION_TYPE = 'NAVIGATION_SHORTCUT'; const CONST = { ANDROID_PACKAGE_NAME, diff --git a/src/components/AddPlaidBankAccount.js b/src/components/AddPlaidBankAccount.js index 77ca9a604237..6570462f1200 100644 --- a/src/components/AddPlaidBankAccount.js +++ b/src/components/AddPlaidBankAccount.js @@ -76,7 +76,7 @@ class AddPlaidBankAccount extends React.Component { super(props); this.getPlaidLinkToken = this.getPlaidLinkToken.bind(this); - this.subscribedKeyboardShortcuts = [] + this.subscribedKeyboardShortcuts = []; } componentDidMount() { @@ -91,9 +91,9 @@ class AddPlaidBankAccount extends React.Component { componentDidUpdate(prevProps) { // block keyboard shortcuts that can navigate when plaid modal is shown if (lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0) { - this.unblockKeyboardShortcuts() + this.unblockKeyboardShortcuts(); } else { - this.blockKeyboardShortcuts() + this.blockKeyboardShortcuts(); } if (!prevProps.network.isOffline || this.props.network.isOffline || this.isAuthenticatedWithPlaid()) { @@ -105,39 +105,7 @@ class AddPlaidBankAccount extends React.Component { } componentWillUnmount() { - this.unblockKeyboardShortcuts() - } - - /** - * Blocks the keyboard shortcuts that can navigate - */ - blockKeyboardShortcuts() { - // return early if shortcuts already blocked - if (this.subscribedKeyboardShortcuts.length > 0) return - - // find and block the shortcuts - const shortcutsToBlock = Object.values(CONST.KEYBOARD_SHORTCUTS).filter(x => x.type === CONST.KEYBOARD_SHORTCUTS_TYPES.NAVIGATION_SHORTCUT) - const unsubscribeCallbacks = shortcutsToBlock.map(shortcut => { - return KeyboardShortcut.subscribe( - shortcut.shortcutKey, - () => {}, // do nothing - shortcut.descriptionKey, - shortcut.modifiers, - false, - false, // stop bubbling - ) - }) - this.subscribedKeyboardShortcuts = unsubscribeCallbacks - } - - /** - * Unblocks the keyboard shortcuts that can navigate - */ - unblockKeyboardShortcuts() { - if (this.subscribedKeyboardShortcuts.length > 0) { - _.each(this.subscribedKeyboardShortcuts, unsubscribe => unsubscribe()); - this.subscribedKeyboardShortcuts = [] - } + this.unblockKeyboardShortcuts(); } /** @@ -162,6 +130,43 @@ class AddPlaidBankAccount extends React.Component { || !_.isEmpty(lodashGet(this.props.plaidData, 'errors'))); } + /** + * Blocks the keyboard shortcuts that can navigate + */ + blockKeyboardShortcuts() { + // return early if shortcuts already blocked + if (this.subscribedKeyboardShortcuts.length > 0) { + return; + } + + // find and block the shortcuts + const shortcutsToBlock = _.filter(CONST.KEYBOARD_SHORTCUTS, (x) => x.type === CONST.KEYBOARD_SHORTCUTS_TYPES.NAVIGATION_SHORTCUT); + const unsubscribeCallbacks = _.map( + shortcutsToBlock, + (shortcut) => { + return KeyboardShortcut.subscribe( + shortcut.shortcutKey, + () => {}, // do nothing + shortcut.descriptionKey, + shortcut.modifiers, + false, + false, // stop bubbling + ); + } + ); + this.subscribedKeyboardShortcuts = unsubscribeCallbacks; + } + + /** + * Unblocks the keyboard shortcuts that can navigate + */ + unblockKeyboardShortcuts() { + if (this.subscribedKeyboardShortcuts.length > 0) { + _.each(this.subscribedKeyboardShortcuts, unsubscribe => unsubscribe()); + this.subscribedKeyboardShortcuts = []; + } + } + render() { const plaidBankAccounts = lodashGet(this.props.plaidData, 'bankAccounts') || []; const token = this.getPlaidLinkToken(); From 28c7e9cf42c221b7037fed0f9b352acdf2db36d3 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed <68777211+huzaifa-99@users.noreply.github.com> Date: Fri, 5 May 2023 06:31:01 +0500 Subject: [PATCH 03/10] Fix lint issues --- src/components/AddPlaidBankAccount.js | 28 ++++++++++++--------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/components/AddPlaidBankAccount.js b/src/components/AddPlaidBankAccount.js index 6570462f1200..dae589573c60 100644 --- a/src/components/AddPlaidBankAccount.js +++ b/src/components/AddPlaidBankAccount.js @@ -137,22 +137,20 @@ class AddPlaidBankAccount extends React.Component { // return early if shortcuts already blocked if (this.subscribedKeyboardShortcuts.length > 0) { return; - } + } // find and block the shortcuts const shortcutsToBlock = _.filter(CONST.KEYBOARD_SHORTCUTS, (x) => x.type === CONST.KEYBOARD_SHORTCUTS_TYPES.NAVIGATION_SHORTCUT); const unsubscribeCallbacks = _.map( shortcutsToBlock, - (shortcut) => { - return KeyboardShortcut.subscribe( - shortcut.shortcutKey, - () => {}, // do nothing - shortcut.descriptionKey, - shortcut.modifiers, - false, - false, // stop bubbling - ); - } + (shortcut) => KeyboardShortcut.subscribe( + shortcut.shortcutKey, + () => {}, // do nothing + shortcut.descriptionKey, + shortcut.modifiers, + false, + false, // stop bubbling + ), ); this.subscribedKeyboardShortcuts = unsubscribeCallbacks; } @@ -161,10 +159,8 @@ class AddPlaidBankAccount extends React.Component { * Unblocks the keyboard shortcuts that can navigate */ unblockKeyboardShortcuts() { - if (this.subscribedKeyboardShortcuts.length > 0) { - _.each(this.subscribedKeyboardShortcuts, unsubscribe => unsubscribe()); - this.subscribedKeyboardShortcuts = []; - } + _.each(this.subscribedKeyboardShortcuts, unsubscribe => unsubscribe()); + this.subscribedKeyboardShortcuts = []; } render() { @@ -257,4 +253,4 @@ export default compose( initWithStoredValues: false, }, }), -)(AddPlaidBankAccount); \ No newline at end of file +)(AddPlaidBankAccount); From 18420e3bb218adb315e594e97209f5d2174bac5b Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed <68777211+huzaifa-99@users.noreply.github.com> Date: Fri, 5 May 2023 06:45:52 +0500 Subject: [PATCH 04/10] Fix lint issues --- src/components/AddPlaidBankAccount.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/AddPlaidBankAccount.js b/src/components/AddPlaidBankAccount.js index dae589573c60..1fd00c1b09c7 100644 --- a/src/components/AddPlaidBankAccount.js +++ b/src/components/AddPlaidBankAccount.js @@ -140,10 +140,10 @@ class AddPlaidBankAccount extends React.Component { } // find and block the shortcuts - const shortcutsToBlock = _.filter(CONST.KEYBOARD_SHORTCUTS, (x) => x.type === CONST.KEYBOARD_SHORTCUTS_TYPES.NAVIGATION_SHORTCUT); + const shortcutsToBlock = _.filter(CONST.KEYBOARD_SHORTCUTS, x => x.type === CONST.KEYBOARD_SHORTCUTS_TYPES.NAVIGATION_SHORTCUT); const unsubscribeCallbacks = _.map( shortcutsToBlock, - (shortcut) => KeyboardShortcut.subscribe( + shortcut => KeyboardShortcut.subscribe( shortcut.shortcutKey, () => {}, // do nothing shortcut.descriptionKey, From c29e02d1c9a9b69587a976b9cf9c9598921215ed Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed <68777211+huzaifa-99@users.noreply.github.com> Date: Fri, 5 May 2023 20:38:25 +0500 Subject: [PATCH 05/10] Removed empty type strings for keyboard shortcut consts --- src/CONST.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index f1a72b37e0e9..1b84319856e8 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -279,7 +279,6 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: 'j', modifierFlags: keyModifierCommand}, [PLATFORM_IOS]: {input: 'j', modifierFlags: keyModifierCommand}, }, - type: '', }, ESCAPE: { descriptionKey: 'escape', @@ -290,7 +289,6 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: keyInputEscape}, [PLATFORM_IOS]: {input: keyInputEscape}, }, - type: '', }, ENTER: { descriptionKey: null, @@ -301,7 +299,6 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: keyInputEnter}, [PLATFORM_IOS]: {input: keyInputEnter}, }, - type: '', }, CTRL_ENTER: { descriptionKey: null, @@ -312,7 +309,6 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: keyInputEnter, modifierFlags: keyModifierCommand}, [PLATFORM_IOS]: {input: keyInputEnter, modifierFlags: keyModifierCommand}, }, - type: '', }, COPY: { descriptionKey: 'copy', @@ -323,7 +319,6 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: 'c', modifierFlags: keyModifierCommand}, [PLATFORM_IOS]: {input: 'c', modifierFlags: keyModifierCommand}, }, - type: '', }, ARROW_UP: { descriptionKey: null, @@ -334,7 +329,6 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: keyInputUpArrow}, [PLATFORM_IOS]: {input: keyInputUpArrow}, }, - type: '', }, ARROW_DOWN: { descriptionKey: null, @@ -345,13 +339,11 @@ const CONST = { [PLATFORM_OS_MACOS]: {input: keyInputDownArrow}, [PLATFORM_IOS]: {input: keyInputDownArrow}, }, - type: '', }, TAB: { descriptionKey: null, shortcutKey: 'Tab', modifiers: [], - type: '', }, }, KEYBOARD_SHORTCUTS_TYPES: { From 61590d3200fad738dd9b2a9cf0a960ccd2b497c4 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed <68777211+huzaifa-99@users.noreply.github.com> Date: Mon, 8 May 2023 16:36:58 +0500 Subject: [PATCH 06/10] Listen to navigation key shortcuts in component mount lifecycle --- src/components/AddPlaidBankAccount.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/components/AddPlaidBankAccount.js b/src/components/AddPlaidBankAccount.js index 1fd00c1b09c7..ad50275ae1cc 100644 --- a/src/components/AddPlaidBankAccount.js +++ b/src/components/AddPlaidBankAccount.js @@ -80,6 +80,8 @@ class AddPlaidBankAccount extends React.Component { } componentDidMount() { + this.subscribeToNavigationShortcuts(); + // If we're coming from Plaid OAuth flow then we need to reuse the existing plaidLinkToken if (this.isAuthenticatedWithPlaid()) { return; @@ -89,13 +91,6 @@ class AddPlaidBankAccount extends React.Component { } componentDidUpdate(prevProps) { - // block keyboard shortcuts that can navigate when plaid modal is shown - if (lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0) { - this.unblockKeyboardShortcuts(); - } else { - this.blockKeyboardShortcuts(); - } - if (!prevProps.network.isOffline || this.props.network.isOffline || this.isAuthenticatedWithPlaid()) { return; } @@ -105,7 +100,7 @@ class AddPlaidBankAccount extends React.Component { } componentWillUnmount() { - this.unblockKeyboardShortcuts(); + this.unsubscribeToNavigationShortcuts(); } /** @@ -133,7 +128,7 @@ class AddPlaidBankAccount extends React.Component { /** * Blocks the keyboard shortcuts that can navigate */ - blockKeyboardShortcuts() { + subscribeToNavigationShortcuts() { // return early if shortcuts already blocked if (this.subscribedKeyboardShortcuts.length > 0) { return; @@ -149,7 +144,8 @@ class AddPlaidBankAccount extends React.Component { shortcut.descriptionKey, shortcut.modifiers, false, - false, // stop bubbling + // stop bubbling when there are bank accounts + () => lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0, ), ); this.subscribedKeyboardShortcuts = unsubscribeCallbacks; @@ -158,7 +154,7 @@ class AddPlaidBankAccount extends React.Component { /** * Unblocks the keyboard shortcuts that can navigate */ - unblockKeyboardShortcuts() { + unsubscribeToNavigationShortcuts() { _.each(this.subscribedKeyboardShortcuts, unsubscribe => unsubscribe()); this.subscribedKeyboardShortcuts = []; } From 4356b3c5f94ab7e1f75977240769b530aa2495b2 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed <68777211+huzaifa-99@users.noreply.github.com> Date: Mon, 8 May 2023 16:45:01 +0500 Subject: [PATCH 07/10] Fix lint issues --- src/components/AddPlaidBankAccount.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/AddPlaidBankAccount.js b/src/components/AddPlaidBankAccount.js index ad50275ae1cc..df9edecfed45 100644 --- a/src/components/AddPlaidBankAccount.js +++ b/src/components/AddPlaidBankAccount.js @@ -144,8 +144,7 @@ class AddPlaidBankAccount extends React.Component { shortcut.descriptionKey, shortcut.modifiers, false, - // stop bubbling when there are bank accounts - () => lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0, + () => lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0, // stop bubbling when there are bank accounts ), ); this.subscribedKeyboardShortcuts = unsubscribeCallbacks; From 726095baac57f8fb0bb949a19753721dd998c9e1 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed <68777211+huzaifa-99@users.noreply.github.com> Date: Mon, 8 May 2023 16:58:16 +0500 Subject: [PATCH 08/10] Updated comment --- src/components/AddPlaidBankAccount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AddPlaidBankAccount.js b/src/components/AddPlaidBankAccount.js index df9edecfed45..ec69c7039895 100644 --- a/src/components/AddPlaidBankAccount.js +++ b/src/components/AddPlaidBankAccount.js @@ -144,7 +144,7 @@ class AddPlaidBankAccount extends React.Component { shortcut.descriptionKey, shortcut.modifiers, false, - () => lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0, // stop bubbling when there are bank accounts + () => lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0, // start bubbling when there are bank accounts ), ); this.subscribedKeyboardShortcuts = unsubscribeCallbacks; From ae1c69ee277c8843ff354eed5104b5ed3cc7f3cf Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed <68777211+huzaifa-99@users.noreply.github.com> Date: Mon, 8 May 2023 17:36:30 +0500 Subject: [PATCH 09/10] Removed extra failsafe --- src/components/AddPlaidBankAccount.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/AddPlaidBankAccount.js b/src/components/AddPlaidBankAccount.js index ec69c7039895..4cfbac50db99 100644 --- a/src/components/AddPlaidBankAccount.js +++ b/src/components/AddPlaidBankAccount.js @@ -129,11 +129,6 @@ class AddPlaidBankAccount extends React.Component { * Blocks the keyboard shortcuts that can navigate */ subscribeToNavigationShortcuts() { - // return early if shortcuts already blocked - if (this.subscribedKeyboardShortcuts.length > 0) { - return; - } - // find and block the shortcuts const shortcutsToBlock = _.filter(CONST.KEYBOARD_SHORTCUTS, x => x.type === CONST.KEYBOARD_SHORTCUTS_TYPES.NAVIGATION_SHORTCUT); const unsubscribeCallbacks = _.map( From a07dbc95347da5bbc45528fca3b396ab69328001 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed <68777211+huzaifa-99@users.noreply.github.com> Date: Mon, 8 May 2023 22:16:34 +0500 Subject: [PATCH 10/10] Removed extra variable assignment --- src/components/AddPlaidBankAccount.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/AddPlaidBankAccount.js b/src/components/AddPlaidBankAccount.js index 4cfbac50db99..86ded21b096b 100644 --- a/src/components/AddPlaidBankAccount.js +++ b/src/components/AddPlaidBankAccount.js @@ -131,7 +131,7 @@ class AddPlaidBankAccount extends React.Component { subscribeToNavigationShortcuts() { // find and block the shortcuts const shortcutsToBlock = _.filter(CONST.KEYBOARD_SHORTCUTS, x => x.type === CONST.KEYBOARD_SHORTCUTS_TYPES.NAVIGATION_SHORTCUT); - const unsubscribeCallbacks = _.map( + this.subscribedKeyboardShortcuts = _.map( shortcutsToBlock, shortcut => KeyboardShortcut.subscribe( shortcut.shortcutKey, @@ -142,7 +142,6 @@ class AddPlaidBankAccount extends React.Component { () => lodashGet(this.props.plaidData, 'bankAccounts', []).length > 0, // start bubbling when there are bank accounts ), ); - this.subscribedKeyboardShortcuts = unsubscribeCallbacks; } /**