Skip to content

Commit

Permalink
Move the areAllModalsHidden check into shouldAutoFocus of ComposerWit…
Browse files Browse the repository at this point in the history
…hSuggestion

Signed-off-by: Tsaqif <[email protected]>
  • Loading branch information
tsa321 committed Jun 5, 2024
1 parent 961ead8 commit 29992cf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/components/Modal/BaseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ function BaseModal(
};

const handleDismissModal = () => {
hideModal();
ComposerFocusManager.setReadyToFocus(uniqueModalId);
};

Expand Down Expand Up @@ -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}
Expand Down
6 changes: 2 additions & 4 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 29992cf

Please sign in to comment.