From 85e3947600a43774a72bbb8b6ce2af13b133d6f2 Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Wed, 29 May 2024 11:20:50 +0700 Subject: [PATCH 1/2] Fix back button arrow won't back when viewing attachment image and fix open search page with shortcut Signed-off-by: Tsaqif --- src/components/Modal/BaseModal.tsx | 3 +-- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/Modal/BaseModal.tsx b/src/components/Modal/BaseModal.tsx index b89d576d7274..3a8a5e11b11b 100644 --- a/src/components/Modal/BaseModal.tsx +++ b/src/components/Modal/BaseModal.tsx @@ -139,6 +139,7 @@ function BaseModal( }; const handleDismissModal = () => { + hideModal(); ComposerFocusManager.setReadyToFocus(modalId); }; @@ -215,9 +216,7 @@ function BaseModal( onBackButtonPress={Modal.closeTop} onModalShow={handleShowModal} propagateSwipe={propagateSwipe} - onModalHide={hideModal} onModalWillShow={saveFocusState} - onDismiss={handleDismissModal} onSwipeComplete={() => onClose?.()} swipeDirection={swipeDirection} isVisible={isVisible} diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index ad437f08523c..192a13385056 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -152,8 +152,10 @@ const modalScreenListeners = { beforeRemove: () => { // Clear search input (WorkspaceInvitePage) when modal is closed SearchInputManager.searchInput = ''; - Modal.setModalVisibility(false); - Modal.willAlertModalBecomeVisible(false); + if (Modal.areAllModalsHidden()) { + Modal.setModalVisibility(false); + Modal.willAlertModalBecomeVisible(false); + } }, }; From 29992cf894d0ebcdcb2e20311435638ee1dedf58 Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Wed, 5 Jun 2024 13:16:03 +0700 Subject: [PATCH 2/2] Move the areAllModalsHidden check into shouldAutoFocus of ComposerWithSuggestion Signed-off-by: Tsaqif --- src/components/Modal/BaseModal.tsx | 3 ++- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 6 ++---- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 7 ++++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/Modal/BaseModal.tsx b/src/components/Modal/BaseModal.tsx index 45006f08ea96..e24c5b7c9c80 100644 --- a/src/components/Modal/BaseModal.tsx +++ b/src/components/Modal/BaseModal.tsx @@ -141,7 +141,6 @@ function BaseModal( }; const handleDismissModal = () => { - hideModal(); ComposerFocusManager.setReadyToFocus(uniqueModalId); }; @@ -226,7 +225,9 @@ function BaseModal( onBackButtonPress={Modal.closeTop} onModalShow={handleShowModal} propagateSwipe={propagateSwipe} + onModalHide={hideModal} onModalWillShow={saveFocusState} + onDismiss={handleDismissModal} onSwipeComplete={() => onClose?.()} swipeDirection={swipeDirection} isVisible={isVisible} diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 138cfb15ea76..a160b6765f87 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -154,10 +154,8 @@ const modalScreenListeners = { beforeRemove: () => { // Clear search input (WorkspaceInvitePage) when modal is closed SearchInputManager.searchInput = ''; - if (Modal.areAllModalsHidden()) { - Modal.setModalVisibility(false); - Modal.willAlertModalBecomeVisible(false); - } + Modal.setModalVisibility(false); + Modal.willAlertModalBecomeVisible(false); }, }; diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index cd92f8c75ae1..c2b4bf65f45f 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -46,6 +46,7 @@ import SilentCommentUpdater from '@pages/home/report/ReportActionCompose/SilentC import Suggestions from '@pages/home/report/ReportActionCompose/Suggestions'; import * as EmojiPickerActions from '@userActions/EmojiPickerAction'; import * as InputFocus from '@userActions/InputFocus'; +import * as Modal from '@userActions/Modal'; import * as Report from '@userActions/Report'; import * as User from '@userActions/User'; import CONST from '@src/CONST'; @@ -285,7 +286,11 @@ function ComposerWithSuggestions( const parentReportAction = parentReportActions?.[parentReportActionID ?? ''] ?? null; const shouldAutoFocus = - !modal?.isVisible && isFocused && (shouldFocusInputOnScreenFocus || (isEmptyChat && !ReportActionsUtils.isTransactionThread(parentReportAction))) && shouldShowComposeInput; + !modal?.isVisible && + Modal.areAllModalsHidden() && + isFocused && + (shouldFocusInputOnScreenFocus || (isEmptyChat && !ReportActionsUtils.isTransactionThread(parentReportAction))) && + shouldShowComposeInput; const valueRef = useRef(value); valueRef.current = value;