-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix: Book travel - Book travel animation becomes blank while RHP is dismissed #50199
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
Conversation
src/components/Lottie/index.tsx
Outdated
|
|
||
| // If user is being navigated away, let pause the animation to prevent memory leak. | ||
| useEffect(() => { | ||
| if (!animationRef || !hasNavigatedAway) { |
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.
animationRef always an object
| if (!animationRef || !hasNavigatedAway) { | |
| if (!animationRef.current || !hasNavigatedAway) { |
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.
thanks, I fixed it
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-10-04.at.15.13.22.mp4Android: mWeb ChromeScreen.Recording.2024-10-04.at.15.15.38.mp4iOS: NativeScreen.Recording.2024-10-04.at.14.39.34.mp4iOS: mWeb SafariScreen.Recording.2024-10-04.at.14.44.58.mp4MacOS: Chrome / SafariScreen.Recording.2024-10-04.at.14.33.01.mp4MacOS: DesktopScreen.Recording.2024-10-04.at.14.34.21.mp4 |
|
@layacat We need to retain the current forwardedRef. I’ve provided the necessary implementation code, so you can proceed with updating the changes accordingly. Please provide feedback if you encounter any issues during the update. |
I didn't find any usages of the forwardRef, do we need to keep it? |
@layacat Currently we have many issues being implement, which maybe involve using ref, so we don’t have the context to remove the forwardRef and keep forwardRef doesn't break the functionality |
|
If we add forwardRef back, we also need to pass the ref everywhere we used Lottie (or maybe where we faced the issue aka the BookTravel - RHP). What do you think? |
@layacat We have two refs in this case: one is the forwardRef, and the other is an internal ref called animationRef. ref={(ref) => {
if (typeof forwardedRef === 'function') {
forwardedRef(ref);
} else if (forwardedRef && 'current' in forwardedRef) {
forwardedRef.current = ref; // this is an external ref
}
animationRef.current = ref; // this is an internal ref will handle pause animation
}} |
|
I see. Thanks for the advice. Let me update the PR. |
|
updated @suneox |
src/components/Lottie/index.tsx
Outdated
| {...props} | ||
| source={animationFile} | ||
| ref={ref} | ||
| ref={animationRef} |
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.
Please keep current forward ref
| ref={animationRef} | |
| ref={(ref) => { | |
| if (typeof forwardedRef === 'function') { | |
| forwardedRef(ref); | |
| } else if (forwardedRef && 'current' in forwardedRef) { | |
| // eslint-disable-next-line no-param-reassign | |
| forwardedRef.current = ref; | |
| } | |
| animationRef.current = ref; | |
| }} |
src/components/Lottie/index.tsx
Outdated
|
|
||
| function Lottie({source, webStyle, shouldLoadAfterInteractions, ...props}: Props, ref: ForwardedRef<LottieView>) { | ||
| function Lottie({source, webStyle, shouldLoadAfterInteractions, ...props}: Props) { | ||
| const animationRef = useRef<LottieView>(null); |
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.
Allow nullable for reassign ref
| const animationRef = useRef<LottieView>(null); | |
| const animationRef = useRef<LottieView | null>(null); |
|
@layacat any specific reason to force push the commits? It is not really preferred as it removes commit history and makes reviewing (following conversation and code changes) bit challenging |
Sorry, I'm familiar with rebase flow (my company used it as the mandatory rule) so I did it as a habit. I will try to do merge flow from now then. |
MonilBhavsar
left a comment
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.
Thanks!
|
✋ 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/MonilBhavsar in version: 9.0.47-1 🚀
|
|
🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.47-4 🚀
|
| if (!animationRef.current || !hasNavigatedAway) { | ||
| return; | ||
| } | ||
| animationRef?.current?.pause(); |
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.
When the browser back button is used to navigate back to a page containing lottie animation, the paused animation does not animate again as a rerender was needed. We addressed this issue here at #59325
Details
Fixed Issues
$ #49744
PROPOSAL: #49744 (comment)
Tests
Offline tests
Same with Tests
QA Steps
Same with Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.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
android.native.mov
Android: mWeb Chrome
android.web.mov
iOS: Native
iphone.native.mov
iOS: mWeb Safari
iphone.web.mov
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov