-
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
fix: back button returns to expense report after submitting track expense #53065
base: main
Are you sure you want to change the base?
Conversation
@eVoloshchak 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] |
friendly bump @eVoloshchak |
|
||
const trackReport = Navigation.getPreviousTrackReport(linkedTrackedExpenseReportAction?.childReportID); | ||
if (trackReport?.key) { | ||
Navigation.isNavigationReady().then(() => Navigation.removeScreenByKey(trackReport.key)); |
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.
We're calling isNavigationReady()
twice (first from here and then from inside the removeScreenByKey
method itself). Is this intentional?
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.
I added the call isNavigationReady
to fix the bug below with browser back button:
Screen.Recording.2025-01-07.at.23.37.22.mov
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.
@eVoloshchak I just updated the function logics, we don't need to use isNavigationReady
here anymore.
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
|
||
const trackReport = Navigation.getPreviousTrackReport(linkedTrackedExpenseReportAction?.childReportID); | ||
if (trackReport?.key) { | ||
Navigation.isNavigationReady().then(() => Navigation.removeScreenByKey(trackReport.key)); |
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.
Can we move .isNavigationReady()
to removeScreenByKey
function itself? That way we won't have to call it each time manually
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.
In this PR I implemented the same logic without isNavigationReady
, so I think we shouldn't move it to removeScreenByKey
src/libs/Navigation/Navigation.ts
Outdated
@@ -428,6 +428,13 @@ function getTopMostCentralPaneRouteFromRootState() { | |||
return getTopmostCentralPaneRoute(navigationRef.getRootState() as State<RootStackParamList>); | |||
} | |||
|
|||
function getPreviousTrackReport(reportID?: string) { |
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.
There might be a better name for this. The method is universal, it doesn't get the previous track report, it gets the track report route by reportID
src/libs/Navigation/Navigation.ts
Outdated
if (!reportID) { | ||
return null; | ||
} | ||
return navigationRef.getRootState().routes.find((r) => r.name === SCREENS.REPORT && !!r.params && 'reportID' in r.params && r.params.reportID === reportID); |
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.
return navigationRef.getRootState().routes.find((r) => r.name === SCREENS.REPORT && !!r.params && 'reportID' in r.params && r.params.reportID === reportID); | |
return navigationRef.getRootState().routes.find((route) => route.name === SCREENS.REPORT && !!route.params && 'reportID' in route.params && route.params.reportID === reportID); |
const state = navigationRef.getRootState(); | ||
const routes = state.routes.filter((item) => item.key !== key); | ||
|
||
navigationRef.current?.dispatch(() => { |
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.
navigationRef.current?.dispatch(() => { | |
isNavigationReady().then(() => { | |
navigationRef.dispatch((state) => { | |
const routes = state.routes.filter((item) => item.key !== key); |
@eVoloshchak I updated |
Explanation of Change
Fixed Issues
$ #52189
PROPOSAL: #52189 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Screen.Recording.2024-12-04.at.11.39.28.mov
Android: mWeb Chrome
Screen.Recording.2024-12-04.at.11.40.08.mov
iOS: Native
Screen.Recording.2024-12-04.at.11.44.00.mov
iOS: mWeb Safari
Screen.Recording.2024-12-04.at.11.45.16.mov
MacOS: Chrome / Safari
Screen.Recording.2024-12-04.at.11.46.13.mp4
MacOS: Desktop
Screen.Recording.2024-12-04.at.11.50.11.mp4