Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7460,6 +7460,10 @@ const CONST = {
INVITE_ACCOUNTANT: 'inviteAccountant',
ADD_EXPENSE_APPROVALS: 'addExpenseApprovals',
},

MODAL_EVENTS: {
CLOSED: 'modalClosed',
},
} as const;

const CONTINUATION_DETECTION_SEARCH_FILTER_KEYS = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {NavigatorScreenParams} from '@react-navigation/native';
import {useFocusEffect} from '@react-navigation/native';
import type {StackCardInterpolationProps} from '@react-navigation/stack';
import React, {useCallback, useContext, useMemo, useRef} from 'react';
import React, {useCallback, useContext, useEffect, useMemo, useRef} from 'react';
// eslint-disable-next-line no-restricted-imports
import {Animated, InteractionManager} from 'react-native';
import {Animated, DeviceEventEmitter, InteractionManager} from 'react-native';
import NoDropZone from '@components/DragAndDrop/NoDropZone';
import {animatedWideRHPWidth, expandedRHPProgress, innerRHPProgress, secondOverlayProgress, thirdOverlayProgress, WideRHPContext} from '@components/WideRHPContextProvider';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
Expand Down Expand Up @@ -111,6 +111,8 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) {
}, [syncWideRHPKeys, syncSuperWideRHPKeys, clearWideRHPKeysAfterTabChanged]),
);

useEffect(() => () => DeviceEventEmitter.emit(CONST.MODAL_EVENTS.CLOSED), []);
Comment thread
war-in marked this conversation as resolved.
Comment thread
war-in marked this conversation as resolved.

return (
<NarrowPaneContextProvider>
<NoDropZone>
Expand Down
19 changes: 16 additions & 3 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {CommonActions, getPathFromState, StackActions} from '@react-navigation/n
import {Str} from 'expensify-common';
// eslint-disable-next-line you-dont-need-lodash-underscore/omit
import omit from 'lodash/omit';
import {InteractionManager} from 'react-native';
import {DeviceEventEmitter, InteractionManager} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {Writable} from 'type-fest';
Expand Down Expand Up @@ -35,7 +35,7 @@ import setNavigationActionToMicrotaskQueue from './helpers/setNavigationActionTo
import {linkingConfig} from './linkingConfig';
import {SPLIT_TO_SIDEBAR} from './linkingConfig/RELATIONS';
import navigationRef from './navigationRef';
import type {NavigationPartialRoute, NavigationRoute, NavigationStateRoute, ReportsSplitNavigatorParamList, RootNavigatorParamList, State} from './types';
import type {NavigationPartialRoute, NavigationRef, NavigationRoute, NavigationStateRoute, ReportsSplitNavigatorParamList, RootNavigatorParamList, State} from './types';

// Routes which are part of the flow to set up 2FA
const SET_UP_2FA_ROUTES = new Set<Route>([
Expand Down Expand Up @@ -569,11 +569,24 @@ function getReportRouteByID(reportID?: string, routes: NavigationRoute[] = navig

/**
* Closes the modal navigator (RHP, onboarding).
*
* @param options - Configuration object
* @param options.ref - Navigation ref to use (defaults to navigationRef)
* @param options.callback - Optional callback to execute after the modal has finished closing.
* The callback fires when RightModalNavigator unmounts.
*
* For detailed information about dismissing modals,
* see the NAVIGATION.md documentation.
*/
const dismissModal = (ref = navigationRef) => {
const dismissModal = ({ref = navigationRef, callback}: {ref?: NavigationRef; callback?: () => void} = {}) => {
Comment thread
war-in marked this conversation as resolved.
Comment thread
war-in marked this conversation as resolved.
isNavigationReady().then(() => {
if (callback) {
const subscription = DeviceEventEmitter.addListener(CONST.MODAL_EVENTS.CLOSED, () => {
subscription.remove();
callback();
});
}

ref.dispatch({type: CONST.NAVIGATION.ACTION_TYPE.DISMISS_MODAL});
// Let React Navigation finish modal transition
// eslint-disable-next-line @typescript-eslint/no-deprecated
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {InteractionManager, Keyboard, View} from 'react-native';
import {Keyboard, View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import type {GestureResponderEvent} from 'react-native/Libraries/Types/CoreEventTypes';
import FormProvider from '@components/Form/FormProvider';
Expand Down Expand Up @@ -157,11 +157,7 @@ function WorkspaceInviteMessageComponent({
}

Navigation.setNavigationActionToMicrotaskQueue(() => {
Navigation.dismissModal();
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => {
Navigation.navigate(ROUTES.WORKSPACE_MEMBERS.getRoute(policyID));
});
Navigation.dismissModal({callback: () => Navigation.navigate(ROUTES.WORKSPACE_MEMBERS.getRoute(policyID))});
});
};

Expand Down
Loading