From 09f7e21f114e789896694bfdd2c6f6ba4a50f5e1 Mon Sep 17 00:00:00 2001 From: OSBotify <76178356+OSBotify@users.noreply.github.com> Date: Thu, 4 May 2023 15:53:28 -0400 Subject: [PATCH 1/2] Merge pull request #18437 from Expensify/version-BUILD-C8B646A2-4D01-41D4-AF7F-2658697F535F Update version to 1.3.10-4 on main (cherry picked from commit bb13d03b6ef8abfe3bdaf553a4a81b20018c016a) --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 5f5cd2a60c44..6067c4295b0d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -106,8 +106,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001031003 - versionName "1.3.10-3" + versionCode 1001031004 + versionName "1.3.10-4" } splits { diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index adf22a4ee8b0..c5b828482d5e 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -30,7 +30,7 @@ CFBundleVersion - 1.3.10.3 + 1.3.10.4 ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index 1fbf1a32713f..a936a7652fdf 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 1.3.10.3 + 1.3.10.4 diff --git a/package-lock.json b/package-lock.json index 3e8ad0119d36..4431b10d6599 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.3.10-3", + "version": "1.3.10-4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.3.10-3", + "version": "1.3.10-4", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index cef5b1a4f0dd..f5b0ff64efe0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.3.10-3", + "version": "1.3.10-4", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.", From c34e817a67c5a282dae438bc19946ed8d4ed024e Mon Sep 17 00:00:00 2001 From: Aldo Canepa Garay <87341702+aldo-expensify@users.noreply.github.com> Date: Thu, 4 May 2023 12:44:55 -0700 Subject: [PATCH 2/2] Merge pull request #18425 from Expensify/aldo_fix-fix-enter-not-working-s77rt-proposal Only subscribe shortcuts when modal is open (cherry picked from commit dc644fd13b2d09db8796f447e3cc67d747467250) --- src/components/KeyboardShortcutsModal.js | 66 +++++++++++++++--------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/src/components/KeyboardShortcutsModal.js b/src/components/KeyboardShortcutsModal.js index 7dd2adf72585..845a8779a731 100644 --- a/src/components/KeyboardShortcutsModal.js +++ b/src/components/KeyboardShortcutsModal.js @@ -34,53 +34,71 @@ const defaultProps = { class KeyboardShortcutsModal extends React.Component { componentDidMount() { + this.subscribedOpenModalShortcuts = []; + const openShortcutModalConfig = CONST.KEYBOARD_SHORTCUTS.SHORTCUT_MODAL; this.unsubscribeShortcutModal = KeyboardShortcut.subscribe(openShortcutModalConfig.shortcutKey, () => { ModalActions.close(); KeyboardShortcutsActions.showKeyboardShortcutModal(); }, openShortcutModalConfig.descriptionKey, openShortcutModalConfig.modifiers, true); + if (this.props.isShortcutsModalOpen) { + // The modal started open, which can happen if you reload the page when the modal is open. + this.subscribeOpenModalShortcuts(); + } + } + + componentDidUpdate(prevProps) { + if (!prevProps.isShortcutsModalOpen && this.props.isShortcutsModalOpen) { + this.subscribeOpenModalShortcuts(); + } else if (prevProps.isShortcutsModalOpen && !this.props.isShortcutsModalOpen) { + // Modal is closing, remove keyboard shortcuts + this.unsubscribeOpenModalShortcuts(); + } + } + + componentWillUnmount() { + if (this.unsubscribeShortcutModal) { + this.unsubscribeShortcutModal(); + } + this.unsubscribeOpenModalShortcuts(); + } + + /* + * Subscribe shortcuts that only are used when the modal is open + */ + subscribeOpenModalShortcuts() { // Allow closing the modal with the both Enter and Escape keys // Both callbacks have the lowest priority (0) to ensure that they are called before any other callbacks // and configured so that event propagation is stopped after the callback is called (only when the modal is open) const closeShortcutEscapeModalConfig = CONST.KEYBOARD_SHORTCUTS.ESCAPE; - this.unsubscribeCloseEscapeModal = KeyboardShortcut.subscribe(closeShortcutEscapeModalConfig.shortcutKey, () => { + this.subscribedOpenModalShortcuts.push(KeyboardShortcut.subscribe(closeShortcutEscapeModalConfig.shortcutKey, () => { ModalActions.close(); KeyboardShortcutsActions.hideKeyboardShortcutModal(); - }, closeShortcutEscapeModalConfig.descriptionKey, closeShortcutEscapeModalConfig.modifiers, true, true); + }, closeShortcutEscapeModalConfig.descriptionKey, closeShortcutEscapeModalConfig.modifiers, true, true)); const closeShortcutEnterModalConfig = CONST.KEYBOARD_SHORTCUTS.ENTER; - this.unsubscribeCloseEnterModal = KeyboardShortcut.subscribe(closeShortcutEnterModalConfig.shortcutKey, () => { + this.subscribedOpenModalShortcuts.push(KeyboardShortcut.subscribe(closeShortcutEnterModalConfig.shortcutKey, () => { ModalActions.close(); KeyboardShortcutsActions.hideKeyboardShortcutModal(); - }, closeShortcutEnterModalConfig.descriptionKey, closeShortcutEnterModalConfig.modifiers, true, () => !this.props.isShortcutsModalOpen); + }, closeShortcutEnterModalConfig.descriptionKey, closeShortcutEnterModalConfig.modifiers, true)); // Intercept arrow up and down keys to prevent scrolling ArrowKeyFocusManager while this modal is open const arrowUpConfig = CONST.KEYBOARD_SHORTCUTS.ARROW_UP; - this.unsubscribeArrowUpKey = KeyboardShortcut.subscribe(arrowUpConfig.shortcutKey, () => { - }, arrowUpConfig.descriptionKey, arrowUpConfig.modifiers, true, () => !this.props.isShortcutsModalOpen); + this.subscribedOpenModalShortcuts.push(KeyboardShortcut.subscribe(arrowUpConfig.shortcutKey, () => { + }, arrowUpConfig.descriptionKey, arrowUpConfig.modifiers, true)); const arrowDownConfig = CONST.KEYBOARD_SHORTCUTS.ARROW_DOWN; - this.unsubscribeArrowDownKey = KeyboardShortcut.subscribe(arrowDownConfig.shortcutKey, () => { - }, arrowDownConfig.descriptionKey, arrowDownConfig.modifiers, true, () => !this.props.isShortcutsModalOpen); + this.subscribedOpenModalShortcuts.push(KeyboardShortcut.subscribe(arrowDownConfig.shortcutKey, () => { + }, arrowDownConfig.descriptionKey, arrowDownConfig.modifiers, true)); } - componentWillUnmount() { - if (this.unsubscribeShortcutModal) { - this.unsubscribeShortcutModal(); - } - if (this.unsubscribeCloseEscapeModal) { - this.unsubscribeCloseEscapeModal(); - } - if (this.unsubscribeCloseEnterModal) { - this.unsubscribeCloseEnterModal(); - } - if (this.unsubscribeArrowUpKey) { - this.unsubscribeArrowUpKey(); - } - if (this.unsubscribeArrowDownKey) { - this.unsubscribeArrowDownKey(); - } + /* + * Unsubscribe all shortcuts that were subscribed when the modal opened + */ + unsubscribeOpenModalShortcuts() { + _.each(this.subscribedOpenModalShortcuts, unsubscribe => unsubscribe()); + this.subscribedOpenModalShortcuts = []; } /**