fix: opened tab/status is not preserved after switching between pages#58053
fix: opened tab/status is not preserved after switching between pages#58053mountiny merged 6 commits intoExpensify:mainfrom
Conversation
|
@allgandalf Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2025-03-10.at.11.12.38.PM.movAndroid: mWeb ChromeScreen.Recording.2025-03-10.at.11.05.44.PM.moviOS: NativeScreen.Recording.2025-03-10.at.11.03.48.PM.moviOS: mWeb SafariScreen.Recording.2025-03-09.at.12.38.15.AM.movMacOS: Chrome / SafariScreen.Recording.2025-03-09.at.12.36.31.AM.movMacOS: DesktopScreen.Recording.2025-03-09.at.12.39.36.AM.mov |
|
Screen.Recording.2025-03-09.at.12.40.41.AM.mov |
|
Production: Screen.Recording.2025-03-09.at.12.41.44.AM.mov |
| const defaultCannedQuery = buildCannedSearchQuery(); | ||
|
|
||
| const rootState = navigationRef.getRootState() as State<RootNavigatorParamList>; | ||
| const lastSearchNavigator = rootState.routes.findLast((route) => route.name === NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR); |
There was a problem hiding this comment.
Here's the fix for preserving state when navigating from BottomBar:
| const lastSearchNavigator = rootState.routes.findLast((route) => route.name === NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR); | |
| const lastSearchNavigator = rootState.routes.findLast((route) => route.name === NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR); | |
| const lastSearchNavigatorState = lastSearchNavigator && lastSearchNavigator.state && lastSearchNavigator.key ? getPreservedSplitNavigatorState(lastSearchNavigator?.key) : undefined; | |
| const lastSearchRoute = lastSearchNavigatorState?.routes.findLast((route) => route.name === SCREENS.SEARCH.ROOT); |
This solution came from @WojtekBoman - thanks!
A few words about it:
previously Search was "flat" so we didn't need to do any extra steps to try and preserve it's state. The route with params was on the top level of navigation so it worked.
Now we need this extra steps of finding the last search route within the navigator to grab the query.
If you are able to improve the dirty logic expression that I did lastSearchNavigator && lastSearchNavigator.state && lastSearchNavigator.key then feel free 😅
|
@nkdengineer
So the way this mechanism works is that navigators will get unmounted to save memory, if they are covered with other navigators in stack. However we will have the SO in our case const lastSearchNavigatorState = lastSearchNavigator && lastSearchNavigator.key ? getPreservedSplitNavigatorState(lastSearchNavigator?.key) : undefined;this line should now work, and parentRoute will not be undefined. I have tested and it works on my end. In addition you can remove the word Fingers crossed that this works :) |
|
Greate, I will give an update soon. |
mountiny
left a comment
There was a problem hiding this comment.
Thanks, not gonna CP this but lets test this properly in staging
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.1.11-1 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.1.12-7 🚀
|
Explanation of Change
fix: opened tab/status is not preserved after switching between pages
Fixed Issues
$ #57986
PROPOSAL: #57986 (comment)
Tests
Offline tests
Same
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2025-03-08.at.22.17.25.mov
Android: mWeb Chrome
Screen.Recording.2025-03-08.at.22.22.00.mov
iOS: Native
Screen.Recording.2025-03-08.at.22.22.45.mov
iOS: mWeb Safari
Screen.Recording.2025-03-08.at.22.23.40.mov
MacOS: Chrome / Safari
Screen.Recording.2025-03-08.at.22.13.42.mov
MacOS: Desktop
Screen.Recording.2025-03-08.at.22.26.57.mov