fix: discard changes modal not show when using browser back button#56527
fix: discard changes modal not show when using browser back button#56527Beamanator merged 15 commits intoExpensify:mainfrom
Conversation
|
@Ollyws As you can see from MacOS: Chrome / Safari and Android: mWeb Chrome, there's a flickering because we re-navigate back to the merchant page, causing the sliding animation. I wonder if we're okay with that. |
| } | ||
|
|
||
| event.preventDefault(); | ||
| window.history.go(1); |
There was a problem hiding this comment.
Hmm using window.history.go(1); seems a bit hacky to me, what do you think @Beamanator?
There was a problem hiding this comment.
It definitely does look hacky, though we do use window.history in the Modal component a bit 🤔 Is there no other way to do this piece with our Navigate lib?
There was a problem hiding this comment.
Currently I found no other way. Navigation.navigate will rerender the whole merchant page causing all the state (merchant value, discard modal...) to be lost.
There was a problem hiding this comment.
@Ollyws What do you think about my comment above?
There was a problem hiding this comment.
Hmm if you're sure there is no other solution then I don't really see any way around it.
There was a problem hiding this comment.
@Ollyws Cool, would you mind continuing your review then?
|
Is there any way we can get rid of the sliding in animation when we press back, it looks pretty bad: Screen.Recording.2025-03-05.at.12.07.40.mov |
|
@Ollyws I cannot completely disable the sliding animation but just can reduce the duration and make it "smoother" like this: Screen.Recording.2025-03-13.at.17.10.35.movThe problem of the previous implementation is that Instead, we can use |
| return; | ||
| } | ||
| if (shouldNavigateBack.current) { | ||
| setTimeout(() => { |
There was a problem hiding this comment.
Why are we using setTimeout here?
There was a problem hiding this comment.
I don't remember why I added it in the first place but I tested again everything and I believe we don't need it.
|
Great thanks for the changes. Overall looks very close to being ready but any idea why pressing the back button on Android chrome causes selection of the input field and subsequently the keyboard to open? Android_Issue.mov |
|
@Ollyws That's because we're using this hook: Will investigate how to conditionally auto focus. |
|
@Ollyws Just resolved it. |
Reviewer Checklist
Screenshots/VideosAndroid: Native01_Android_Native.mp4Android: mWeb Chrome02_Android_Chrome.mp4iOS: Native04_iOS_Safari.mp4iOS: mWeb Safari05_MacOS_Chrome.mp4MacOS: Chrome / Safari06_MacOS_Desktop.mp4MacOS: Desktop |
|
@Beamanator let us know what you think about the sliding animation, that's really as smooth as we can get it I think. |
Beamanator
left a comment
There was a problem hiding this comment.
Looking great! 2 super tiny comments
| ); | ||
|
|
||
| useEffect(() => { | ||
| const unsubscribe = navigation.addListener('transitionStart', () => { |
There was a problem hiding this comment.
Similarly, can you please add a comment explaining that we know there's a slight "glitchy" looking animation but this was the best we could do (using transitionStart)
In my opinion, if you at least mentioning it in the comments and people ask questions later, it will be good to know we EXPECTED at least a somewhat glitchy animation, as opposed to people thinking it's a bug we overlooked
There was a problem hiding this comment.
Thanks. I added comments.
|
Hmm I did not change those pages. I'll merge main later to see if lint check succeeds. |
Beamanator
left a comment
There was a problem hiding this comment.
Thanks! And yeah weird that the lint issues are in files that didn't change in this PR
|
@Beamanator looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
|
Eslint errors expected, they're on files that weren't changed in this PR 🤔 |
|
✋ 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/Beamanator in version: 9.1.33-0 🚀
|
|
🚀 Deployed to staging by https://github.com/Beamanator in version: 9.1.35-1 🚀
|
|
🚀 Deployed to staging by https://github.com/Beamanator in version: 9.1.36-3 🚀
|
|
🚀 Deployed to staging by https://github.com/Beamanator in version: 9.1.37-1 🚀
|
|
🚀 Deployed to production by https://github.com/thienlnam in version: 9.1.37-3 🚀
|
| // could be less "glitchy" when going back and forth between the previous and current pages | ||
| const unsubscribe = navigation.addListener('transitionStart', () => { | ||
| // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
| if (!getHasUnsavedChanges() || blockedNavigationAction.current || shouldNavigateBack.current) { |
There was a problem hiding this comment.
When clicking on the device back button with the discard confirmation modal open, it goes back to the previous page along with discarding the modal. Fixed here #67010
Explanation of Change
Fixed Issues
$ #55287
PROPOSAL: #55287 (comment)
Tests
[Web & mWeb]
Offline tests
NA
QA Steps
Same as Tests
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-02-07.at.16.47.22-compressed.mov
Android: mWeb Chrome
Screen.Recording.2025-02-07.at.16.45.46-compressed.mov
iOS: Native
Screen.Recording.2025-02-07.at.16.22.49-compressed.mov
iOS: mWeb Safari
Screen.Recording.2025-02-07.at.16.24.55.mov
MacOS: Chrome / Safari
Screen.Recording.2025-02-07.at.16.14.16-compressed.mov
MacOS: Desktop
Screen.Recording.2025-02-07.at.16.23.27-compressed.mov