-
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
Android - Fix scroll on requesting money #31649
Conversation
@narefyev91 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] |
@narefyev91 I was unable to test on |
@@ -24,7 +24,9 @@ function useReportScrollManager(): ReportScrollManagerData { | |||
return; | |||
} | |||
|
|||
flatListRef.current.scrollToOffset({animated: false, offset: 0}); | |||
setTimeout(() => { |
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.
@esh-g can you please add description why we could not avoid using setTimeout.. did you also try to avoid using it? Just to be 100% sure that we tried everything
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 use maybe here InteractionManager.runAfterInteractions - is should works well with native side - can you try that?
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.
@narefyev91 After some more digging, I found the actual root cause! (very sneaky)
We are using a custom Flatlist
for android and it saves the last scrolled point and goes to it after it comes into focus...
props.innerRef.current.scrollToOffset({offset: scrollPosition.offset, animated: false}); |
When the navigation modal is dismissed, this scrolls to the last scrolled point and prevents the reportScrollManager
from working correctly...
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.
good point - i think we can fix that inside specific flatlist for android - can you try to do it?
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.
The current logic seems to be that whenever we scroll the list, the offset is saved and when list is refocused, that offset it set again.
Here are some things that I can brainstorm:
- We can modify the flatlist to make the
scrollPosition
available publicly (possibly with context) instead of using just state and then set thescrollPosition
to0
when dismissing modal
const [scrollPosition, setScrollPosition] = useState({}); - We can somehow prevent the offset from taking place after the focus
But still exploring the options
Hey @esh-g any updates here? |
@narefyev91 I pushed a commit to use the context for |
Navigation.dismissModal(isMoneyRequestReport ? report.reportID : chatReport.reportID); | ||
Report.notifyNewAction(chatReport.reportID, payeeAccountID); | ||
Navigation.dismissModal(activeReportID); | ||
Report.notifyNewAction(activeReportID, payeeAccountID); |
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.
why do we change that from chatReport.reportID to activeReportID? Can you please explain
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.
@narefyev91 We are always subscribed to the report opened in the report screen here:
const unsubscribe = Report.subscribeToNewActionEvent(report.reportID, (isFromCurrentUser) => { |
So when we are in an expense report, chatReport.reportID
which corresponds to currentChatReport
passed to getMoneyRequestInformation
const currentChatReport = isMoneyRequestReport ? ReportUtils.getReport(report.chatReportID) : report;
So, currentChatReport
actually becomes the original report with the other person and not the IOU or expense report. This means that when we notify a new action, we do it on parent report and not the actual expense report when using chatReport.reportID
.
This is why we modified the Navigation.dismissModal
line to use a different reportID
so that the user is redirected to the expense report from where they requested the money. The same logic should be used for notifyNewAction
.
Reviewer Checklist
Screenshots/VideosWeb8mb.video-ji3-eNJbUG79.mp4Mobile Web - Chromeandroid-web.mp4Mobile Web - Safariios-web.mp4Desktopdesktop.mp4iOSios.mp4Androidandroid.mp4 |
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!
Nice that we were able to avoid usage of setTimeout!
🎀 👀 🎀 C+ reviewed
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.
Thank you guys! LGTM, good job for avoiding the setTimeout!
✋ 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 production by https://github.com/mountiny in version: 1.4.6-2 🚀
|
Details
Fixed Issues
$ #31373
PROPOSAL: #31373 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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.2023-11-21.at.10.45.25.PM-1.mov
Android: mWeb Chrome
iOS: Native
Screen.Recording.2023-11-21.at.11.17.19.PM.mov
iOS: mWeb Safari
Screen.Recording.2023-11-21.at.10.43.11.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2023-11-21.at.10.40.09.PM-1.mov
MacOS: Desktop
Screen.Recording.2023-11-21.at.11.11.12.PM.mov