-
Notifications
You must be signed in to change notification settings - Fork 3k
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
luacmartins
merged 4 commits into
Expensify:main
from
software-mansion-labs:fix/search-rhp-native-go-back
Sep 18, 2024
Merged
[Search v2.1] Android & iOS - Search icon is not responsive after returning to LHN from thread #48990
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
babc3c9
Pop home screen when going back to Search RHP
WojtekBoman 86742b3
Merge branch 'main' into fix/search-rhp-native-go-back
WojtekBoman 83ccc2e
Add beforeRemoveReportOpenedFromSearchRHP
WojtekBoman 40bd73f
Cleanup CustomRouter changes
WojtekBoman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/libs/Navigation/AppNavigator/beforeRemoveReportOpenedFromSearchRHP/index.native.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
4 changes: 4 additions & 0 deletions
4
src/libs/Navigation/AppNavigator/beforeRemoveReportOpenedFromSearchRHP/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming from #50111, where there was a crash with a particular navigation scenario. We haven't limited this function to the search RHP, so it's running in unexpected contexts, which is partially what caused the crash. More details in the proposal.