-
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
Show discard confirmation modal when going back from a page with unsaved changes #54176
base: main
Are you sure you want to change the base?
Show discard confirmation modal when going back from a page with unsaved changes #54176
Conversation
@ahmedGaber93 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] |
|
I think the idea to add the discard confirmation logic in FormProvider is a good idea, but I think we should use a prop to control whether to enable it because I'm not confident it will work smooth on all cases (for example, we set isSavedRef to true when press the submit button, but there is a submit button that navigate forward to another page instead of closing it). Let me know if I should update it. |
@@ -53,6 +54,9 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { | |||
} | |||
isExecutingRef.current = true; | |||
navigation.goBack(); | |||
setTimeout(() => { | |||
isExecutingRef.current = false; | |||
}, CONST.ANIMATED_TRANSITION); |
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.
isExecutingRef prevent the user to click the overlay multiple times when going back (I can't repro the multiple click issue even after removing the ref). But since we are preventing the going back when there is unsaved change, the next press won't do anything. So, we need to reset isExecutingRef back.
const updateMerchantRef = (value: string) => { | ||
merchantRef.current = value; | ||
}; | ||
|
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 used ref here (same for desc) so it won't trigger a re-render everytime the value is updated since we only use this for getHasUnsavedChanges
.
title: '¿Descartar cambios?', | ||
body: '¿Estás seguro de que quieres descartar los cambios que hiciste?', | ||
confirmText: 'Descartar cambios', | ||
}, |
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.
Asked for the translation verification here: https://expensify.slack.com/archives/C01GTK53T8Q/p1734322609246139
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.
It approved, Let's add the Slack link in author checklist Link to Slack message:
Reviewer Checklist
Screenshots/VideosAndroid: Nativea.mp4Android: mWeb Chromeaw.mp4iOS: Nativei.mp4iOS: mWeb Safariiw.mp4MacOS: Chrome / Safariw.mp4MacOS: Desktopd.mp4 |
Looks good overall, we just need to fix the conflict and follow ESlint new rule |
Done |
@bernhardoj can we support |
Is the modal doesn't show when using hardware back button? I want to test it but getting error again But I also think we shouldn't use
Done |
Yeah, I agree. It will be difficult to implement. |
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.
LGTM!
@bernhardoj another conflict need to resolved. |
Fixed. |
Explanation of Change
Fixed Issues
$ #53679
PROPOSAL: #53679 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
NOTE for web/desktop: you can test going back by pressing the overlay too
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
android.17.17.49.mp4
Android: mWeb Chrome
android.mweb.17.17.49.mp4
iOS: Native
ios.17.17.49.mp4
iOS: mWeb Safari
ios.mweb.17.17.49.mp4
MacOS: Chrome / Safari
web.merchant.mp4
web-desc.mp4
MacOS: Desktop
desktop.17.17.49.mp4