Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Search v2.1] Android & iOS - Search icon is not responsive after returning to LHN from thread #48990

Merged
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
10 changes: 10 additions & 0 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import type * as OnyxTypes from '@src/types/onyx';
import type {SelectedTimezone, Timezone} from '@src/types/onyx/PersonalDetails';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type ReactComponentModule from '@src/types/utils/ReactComponentModule';
import beforeRemoveReportOpenedFromSearchRHP from './beforeRemoveReportOpenedFromSearchRHP';
import CENTRAL_PANE_SCREENS from './CENTRAL_PANE_SCREENS';
import createCustomStackNavigator from './createCustomStackNavigator';
import defaultScreenOptions from './defaultScreenOptions';
Expand Down Expand Up @@ -107,6 +108,14 @@ function getCentralPaneScreenInitialParams(screenName: CentralPaneName, initialR
return undefined;
}

function getCentralPaneScreenListeners(screenName: CentralPaneName) {
if (screenName === SCREENS.REPORT) {
return {beforeRemove: beforeRemoveReportOpenedFromSearchRHP};
}

return {};
}

function initializePusher() {
Pusher.init({
appKey: CONFIG.PUSHER.APP_KEY,
Expand Down Expand Up @@ -556,6 +565,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
initialParams={getCentralPaneScreenInitialParams(centralPaneName, initialReportID)}
getComponent={componentGetter}
options={CentralPaneScreenOptions}
listeners={getCentralPaneScreenListeners(centralPaneName)}
/>
);
})}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {StackActions} from '@react-navigation/native';
import type {EventArg} from '@react-navigation/native';
import getTopmostBottomTabRoute from '@libs/Navigation/getTopmostBottomTabRoute';
import Navigation from '@libs/Navigation/Navigation';
import navigationRef from '@libs/Navigation/navigationRef';
import type {RootStackParamList, State} from '@libs/Navigation/types';
import NAVIGATORS from '@src/NAVIGATORS';
import SCREENS from '@src/SCREENS';

/**
* When we go back from the chat opened in the Chats section to the chat opened in the Search RHP we have to pop the Home screen from the Bottom tab navigator to display correctly Search page under RHP on native platform.
* It fixes this issue: https://github.com/Expensify/App/issues/48882
*/
function beforeRemoveReportOpenedFromSearchRHP(event: EventArg<'beforeRemove', true>) {
if (!navigationRef.current) {
return;
}

const state = navigationRef.current?.getRootState() as State<RootStackParamList>;

if (!state) {
return;
}

const shouldPopHome =
state.routes?.length >= 3 &&
state.routes.at(-1)?.name === SCREENS.REPORT &&
state.routes.at(-2)?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR &&
getTopmostBottomTabRoute(state)?.name === SCREENS.HOME;

if (!shouldPopHome) {
return;
}

event.preventDefault();
const bottomTabState = state?.routes?.at(0)?.state;
navigationRef.dispatch({...StackActions.pop(), target: bottomTabState?.key});
Navigation.goBack();
}

export default beforeRemoveReportOpenedFromSearchRHP;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** The issue fixed by this handler is related to navigating back on native platforms. For more information, see the index.native.ts file in this folder */
function beforeRemoveReportOpenedFromSearchRHP() {}

export default beforeRemoveReportOpenedFromSearchRHP;
Loading