Skip to content

Commit

Permalink
Merge pull request #22355 from Expensify/vit-fixBlocker22302
Browse files Browse the repository at this point in the history
Do not use the replace in case of RHP as its fixing edge case
  • Loading branch information
mountiny authored Jul 6, 2023
2 parents d98a02a + 97f2539 commit 0d82167
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@ function RigthModalNavigator() {
<Stack.Screen
name="NewGroup"
component={ModalStackNavigators.NewGroupModalStackNavigator}
options={{
// Disable animation for this screen because it causes an animation glitch when using shortcuts
animationEnabled: false,
}}
/>
<Stack.Screen
name="Search"
component={ModalStackNavigators.SearchModalStackNavigator}
options={{
// Disable animation for this screen because it causes an animation glitch when using shortcuts
animationEnabled: false,
}}
/>
<Stack.Screen
name="Details"
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/AppNavigator/RHPScreenOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styles from '../../../styles/styles';

const RHPScreenOptions = {
headerShown: false,
animationEnabled: false,
animationEnabled: true,
gestureDirection: 'horizontal',
cardStyle: styles.navigationScreenCardStyle,
cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
Expand Down
13 changes: 3 additions & 10 deletions src/libs/Navigation/linkTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ import getStateFromPath from './getStateFromPath';
*
* @param {Object} action action generated by getActionFromState
* @param {Object} state The root state
* @returns {{minimalAction: Object, targetName: String}} minimal action is the action that we should dispatch and targetName is the name of the target navigator.
* targetName name is necessary to determine if we are going to use REPLACE for navigating between RHP flows.
* @returns {Object} minimalAction minimal action is the action that we should dispatch
*/
function getMinimalAction(action, state) {
let currentAction = action;
let currentState = state;
let currentTargetKey = null;
let targetName = null;

while (currentState.routes[currentState.index].name === currentAction.payload.name) {
if (!currentState.routes[currentState.index].state) {
break;
}

targetName = currentState.routes[currentState.index].name;
currentState = currentState.routes[currentState.index].state;

currentTargetKey = currentState.key;
Expand All @@ -40,7 +37,7 @@ function getMinimalAction(action, state) {
target: currentTargetKey,
};
}
return {minimalAction: currentAction, targetName};
return currentAction;
}

export default function linkTo(navigation, path, type) {
Expand Down Expand Up @@ -79,12 +76,8 @@ export default function linkTo(navigation, path, type) {
}

if (action.payload.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) {
const {minimalAction, targetName} = getMinimalAction(action, navigation.getRootState());
const minimalAction = getMinimalAction(action, navigation.getRootState());
if (minimalAction) {
// If the target name is RHP that means this action is responsible for changing flow within the RHP e.g. from settings to search. In that case we want to use REPLACE.
if (targetName === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) {
minimalAction.type = 'REPLACE';
}
root.dispatch(minimalAction);
return;
}
Expand Down

0 comments on commit 0d82167

Please sign in to comment.