Skip to content

Commit

Permalink
Merge pull request #38734 from software-mansion-labs/fix/opening-rhp-…
Browse files Browse the repository at this point in the history
…in-fullscreen

Fix opening FullScreenNavigator from the Home page
  • Loading branch information
mountiny authored Mar 27, 2024
2 parents f8416e9 + 703c27e commit fecb709
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/libs/Navigation/linkTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export default function linkTo(navigation: NavigationContainerRef<RootStackParam
}
let root: NavigationRoot = navigation;
let current: NavigationRoot | undefined;

// Traverse up to get the root navigation
// eslint-disable-next-line no-cond-assign
while ((current = root.getParent())) {
Expand All @@ -145,7 +144,6 @@ export default function linkTo(navigation: NavigationContainerRef<RootStackParam
}

const action: StackNavigationAction = getActionFromState(stateFromPath, linkingConfig.config);

// If action type is different than NAVIGATE we can't change it to the PUSH safely
if (action?.type === CONST.NAVIGATION.ACTION_TYPE.NAVIGATE) {
const topmostCentralPaneRoute = getTopmostCentralPaneRoute(rootState);
Expand Down Expand Up @@ -181,12 +179,11 @@ export default function linkTo(navigation: NavigationContainerRef<RootStackParam
} else if (type === CONST.NAVIGATION.TYPE.UP) {
action.type = CONST.NAVIGATION.ACTION_TYPE.REPLACE;

// If this action is navigating to the ModalNavigator and the last route on the root navigator is not already opened ModalNavigator then push
} else if (isModalNavigator(action.payload.name) && !isTargetNavigatorOnTop) {
// If this action is navigating to ModalNavigator or FullScreenNavigator and the last route on the root navigator is not already opened Navigator then push
} else if ((action.payload.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR || isModalNavigator(action.payload.name)) && !isTargetNavigatorOnTop) {
if (isModalNavigator(topRouteName)) {
dismissModal(navigation);
}
action.type = CONST.NAVIGATION.ACTION_TYPE.PUSH;

// If this RHP has mandatory central pane and bottom tab screens defined we need to push them.
const {adaptedState, metainfo} = getAdaptedStateFromPath(path, linkingConfig.config);
Expand All @@ -197,6 +194,12 @@ export default function linkTo(navigation: NavigationContainerRef<RootStackParam
root.dispatch(diffAction);
}
}
// All actions related to FullScreenNavigator are pushed when comparing differences between rootState and adaptedState.
if (action.payload.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR) {
return;
}
action.type = CONST.NAVIGATION.ACTION_TYPE.PUSH;

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
} else if (action.payload.name === NAVIGATORS.BOTTOM_TAB_NAVIGATOR) {
// If path contains a policyID, we should invoke the navigate function
Expand Down
3 changes: 0 additions & 3 deletions src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,6 @@ function getAdaptedState(state: PartialState<NavigationState<RootStackParamList>
// - default central pane on desktop layout
// - found fullscreen

// Full screen navigator can have any central pane and bottom tab under. They will be covered anyway.
metainfo.isCentralPaneAndBottomTabMandatory = false;

const routes = [];
routes.push(
createBottomTabNavigator(
Expand Down

0 comments on commit fecb709

Please sign in to comment.