-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 image moves permanently when swipe down #51921
Fix image moves permanently when swipe down #51921
Conversation
Additional videos: Double tap zoom: double.tap.zoom.mp4Pinch: pinch.mp4Avatar crop modal: avatar.mp4 |
@bernhardoj If we have just one image, everything looks fine to me, but if we upload two images, especially with different heights, then swipe a bit to the side, so that you can see both images, and then swipe down, something strange is happening: 51921_ios_native_bug.movCan you reproduce it? I haven't tested it in |
Not exactly the same, but it always behave strangely after uploading a new image, on main too. asd.mp4ios.mp4 |
Reviewer Checklist
Screenshots/VideosAndroid: Native51921_android_native.movAndroid: mWeb Chrome51921_android_web.moviOS: Native51921_ios_native.moviOS: mWeb Safari51921_ios_web.movMacOS: Chrome / Safari51921_web_chorme.movMacOS: Desktop51921_web_desktop.mov |
True, however, apart from this strange behavior, I believe that the problem we are trying to solve still persists, If we only have one image, everything works fine, with two: Screen.Recording.2024-11-04.at.15.29.19.movWhat do you think @bernhardoj? |
I'll take a look. |
Gerat! Let me know if I can help in any way. |
I'm having problem with my iOS. It doesn't respond to press. |
It works normally back and I can repro this. The root cause is that the App/src/components/MultiGestureCanvas/usePanGesture.ts Lines 233 to 238 in afa7b33
From the comment, looks like it's expected? |
I see, thanks for clarifying, that makes sense. @bernhardoj what do you think about preventing swiping in more than one direction? Example: preventing "swiping sideways" if we are performing another gesture, in this case "swiping down". Not allowing two movements to be made at the same time. I tested it on Whatsapp and this is how they do it there, I couldn't record a video to illustrate it better, but if it wasn't clear, let me know. Do you think it would be feasible here? Thank you. |
Yeah, I prefer to prevent that too, but I think we need the team's input first about changing this behavior. |
Yeah I totally agree with the suggestion of only allowing swiping in one direction at a time 👍 |
Nice. @bernhardoj do you think we can make these changes here? Thanks. |
Updated. Please check |
Nice! Looking good, except for one detail: when adding a new photo, we could skip the upload by swiping the image down: iOS: Native - mainScreen.Recording.2024-11-11.at.10.49.36.movNow, after the changes, I can't: iOS: Native - testing PRScreen.Recording.2024-11-11.at.10.50.37.mov@bernhardoj, was that intentional? Other than that, everything else looks great. |
} | ||
// eslint-disable-next-line react-compiler/react-compiler, no-param-reassign | ||
isPagerScrollEnabled.value = !current; | ||
}, |
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.
Fixed. In non-carousel, changing isScrollEnabled, changes the nope
shared value here
App/src/components/AttachmentModal.tsx
Lines 474 to 475 in 64cb4ee
isPagerScrolling: nope, | |
isScrollEnabled: nope, |
which sets isPagerScrolling
to true too, disabling the pan gesture.
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
Thanks for the changes @bernhardoj, in native everything looks good now: Android: Native51921_android_native.moviOS: Native51921_ios_native.movHowever, in mobile web, when we already have some images uploaded, I can't dismiss the image by swiping down: Android: mWeb Chrome51921_android_web.moviOS: mWeb Safari51921_ios_web.movOtherwise everything looks fine: MacOS: Chrome / Safari51921_web_chorme.movMacOS: Desktop51921_web_desktop.movLet me know if I can help in any way. Thank you. |
@@ -201,12 +201,12 @@ function AttachmentCarousel({report, source, onNavigate, setDownloadButtonVisibi | |||
activePage: 0, | |||
pagerRef, | |||
isPagerScrolling: nope, | |||
isScrollEnabled: nope, | |||
isScrollEnabled, |
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.
Fixed. Same with the previous issue.
Sorry @bernhardoj, but it seems to be worse on mWeb: mobile_mWebmobile_mWeb.movIn native still fine: nativenative.movDo you have any idea what it could be? Let me know if you find anything. |
scrollTo(scrollRef, page * cellWidth - translationX, 0, false); | ||
}) | ||
.onEnd(({translationX, velocityX}) => { | ||
if (scale.current !== 1) { | ||
if (!isScrollEnabled.value) { | ||
return; | ||
} |
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.
Fixed. The scroll stuck because we swipe down while scrolling, making isScrollEnabled
false. Now I update isPagerScrolling
while scrolling.
@@ -253,11 +257,12 @@ function AttachmentCarousel({report, source, onNavigate, setDownloadButtonVisibi | |||
newIndex = Math.min(attachments.length - 1, Math.max(0, page + delta)); | |||
} | |||
|
|||
isPagerScrolling.value = false; | |||
scrollTo(scrollRef, newIndex * cellWidth, 0, true); |
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 is no completion callback when the scroll animation is complete.
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.
Great job @bernhardoj, everything looks good to me now. I retested on all platforms and updated the videos.
One last thing, is there another test we should add to cover the slightly changed behaviour?
|
Well noted @Julesssss. @bernhardoj can you update the Test Steps for us? Thank you. |
Added the test. |
Thank you @bernhardoj! What do you think @Julesssss? Thanks. |
Thanks, looks good. |
✋ 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/Julesssss in version: 9.0.62-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.0.62-4 🚀
|
Explanation of Change
When swiping down an image attachment, it doesn't go back to its place. The root of the issue is the function that captured an old canvas value. This PR fixes it by making sure the canvas size is added to the useCallback deps.
Fixed Issues
$ #51465
PROPOSAL: #51465 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
Web/Desktop: There is no swipe
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.mp4
Android: mWeb Chrome
iOS: Native
ios.mp4
iOS: mWeb Safari
ios.mweb.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4