Skip to content

Commit

Permalink
Merge pull request #37130 from bernhardoj/fix/36604-blank-report-screen
Browse files Browse the repository at this point in the history
Fix central screen is blank when using search shortcut from attachment preview
  • Loading branch information
amyevans authored Feb 27, 2024
2 parents d561cf7 + d3a6c18 commit d2a9c6f
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {NavigationState, PartialState} from '@react-navigation/native';
import type {NavigationState, PartialState, Route} from '@react-navigation/native';
import {getStateFromPath} from '@react-navigation/native';
import {isAnonymousUser} from '@libs/actions/Session';
import getIsNarrowLayout from '@libs/getIsNarrowLayout';
Expand Down Expand Up @@ -151,6 +151,8 @@ function getAdaptedState(state: PartialState<NavigationState<RootStackParamList>
const fullScreenNavigator = state.routes.find((route) => route.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR);
const rhpNavigator = state.routes.find((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR);
const lhpNavigator = state.routes.find((route) => route.name === NAVIGATORS.LEFT_MODAL_NAVIGATOR);
const reportAttachmentsScreen = state.routes.find((route) => route.name === SCREENS.REPORT_ATTACHMENTS);

if (rhpNavigator) {
// Routes
// - matching bottom tab
Expand Down Expand Up @@ -257,6 +259,26 @@ function getAdaptedState(state: PartialState<NavigationState<RootStackParamList>
metainfo,
};
}
if (reportAttachmentsScreen) {
// Routes
// - matching bottom tab
// - central pane (report screen) of the attachment
// - found report attachments
const routes = [];
const reportAttachments = reportAttachmentsScreen as Route<'ReportAttachments', RootStackParamList['ReportAttachments']>;

const matchingBottomTabRoute = getMatchingBottomTabRouteForState(state);
routes.push(createBottomTabNavigator(matchingBottomTabRoute, policyID));
if (!isNarrowLayout) {
routes.push(createCentralPaneNavigator({name: SCREENS.REPORT, params: {reportID: reportAttachments.params?.reportID ?? ''}}));
}
routes.push(reportAttachments);

return {
adaptedState: getRoutesWithIndex(routes),
metainfo,
};
}
if (bottomTabNavigator) {
// Routes
// - found bottom tab
Expand Down

0 comments on commit d2a9c6f

Please sign in to comment.