-
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
Fix crash when edit a message after coming back from a child report #21227
Conversation
Here are a few additional recordings to test if other things still work as normally:
web.auto.scroll.movios.auto.scroll.movNote that the auto-scroll after doing a money request does not work on a small screen except in iOS native. This also happens in
Screen.Recording.2023-06-22.at.00.34.47.mov
Screen.Recording.2023-06-22.at.00.52.08.mov |
@fedirjh please have a look when you have the time |
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.
Looks good , left some comments
@@ -47,7 +47,7 @@ const defaultProps = { | |||
}; | |||
|
|||
function ReportActionItemReactions(props) { | |||
const reactionListRef = useContext(ReactionListRefContext); | |||
const {reactionListRef} = useContext(ReportScreenContext); |
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.
As this is a functional component, why we don't just use useReportScrollManager
? we should export refs from the hooks.
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.
This one is reactionListRef, not the flat list one 😄
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.
But we use the same context ? inside the useReportScrollManager
we should export both refs and use each ref accordingly .
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 think that would be weird useReportScrollManager exporting reaction list ref. Reaction list does not belong to report scroll manager
flatListRef.current.scrollToOffset({animated: false, offset: 0}); | ||
}; | ||
|
||
return {scrollToIndex, scrollToBottom}; |
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 think we should export the ref flatListRef
so we can use this hook in functional component.
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.
Done
* @param {Object} index | ||
* @param {Boolean} isEditing | ||
*/ | ||
function scrollToIndex(index, isEditing) { | ||
function scrollToIndex(ref, index, isEditing) { |
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.
Let's add safety checks here
if (!ref.current) {
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.
Done
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.
Sorry for this but it could be simplified
if (!ref.current || isEditing) { return; }
Let's add safety checks for all other methods
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.
Updated. Added in the hooks too
@@ -78,6 +78,7 @@ function keyExtractor(item) { | |||
} | |||
|
|||
function ReportActionsList(props) { | |||
const {flatListRef} = useContext(ReportScreenContext); |
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.
Here as well we should use the hook to get the ref.
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.
Done
onConfirm={createTransaction} | ||
onSendMoney={sendMoney} |
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 this change ?
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.
ReportScrollManager.scrollToBottom is removed leaving
onConfirm={(selectedParticipants) => createTransaction(selectedParticipants)}
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.
hmm I was asking about removing ReportScrollManager.scrollToBottom
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.
Ah, that's because we can't have ReportScreenContext inside MoneyRequestConfirmPage. That's why I use Report.notifyNewAction
approach to replace 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.
Thank you , that make sense
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 it was added in the first place
So, previously all money request page (amount, participants, confirm) is placed inside MoneyRequestModal. What the PR #17964 did is separate each page into its own screen. So, all the logic there is already been there before the PR.
The changes included in this PR will break the rule in this comment, we will not have one source of truth
No, it won't. Whether we receive the event from Pusher, add a new comment from Report.addActions, or create a new money request, all of them use notifyNewAction
that will trigger the callback which is our source of truth.
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.
So, all the logic there is already been there before the PR.
Aha , I found the PR that introduced the changes : #15820
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 found the same approach you implemented , was suggested before in this proposal , I am not sure why we didn’t go with this approach before 🤔
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.
Huh, so the PR is just a few months ago. I expected it about a year ago 😂.
I am not sure why we didn’t go with this approach before
I guess it's much simpler using ReportScrollManager.scrollToBottom
, but this is an interesting find.
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 guess it's much #15540 (comment) using ReportScrollManager.scrollToBottom
Yeah that seems the case.
@bernhardo we have a bug , here is step to reproduce :
Expected result: it should scroll to the open edit input Simulator.Screen.Recording.-.iPhone.14.-.2023-06-23.at.17.34.13.mp4We have this warning as well ![]() |
I think it's related to the ref warning. Btw, is it a new feature to auto-scroll to edit composer? I found it annoying when the message we edit is far at the top which is not mounted on the screen yet. When we scroll up, it will suddenly auto-scroll to the edit composer which distracts the user. Screen.Recording.2023-06-24.at.12.24.27.mov
I forget to export the ref in |
Nope, this is an old feature , It was working like that before this PR.
Maybe we can report that as a new issue. This feature doesn’t not always works , I already raised some concerns about it here #20847 (comment) |
@bernhardoj The reaction picker is not showing after we go back from threads. It doesn’t not work on
Bug.mp4 |
Yes, there is an issue for that here #21101. The one that I included in the test is the reaction list. (long press this one) |
I think as the fix is simple we can include it in this PR ? for the bounty we can discuss that later on the 2nd issue. I see that there is only one proposal from |
@bernhardoj Let me know if we can cover that bug is this PR. |
Yep, it's quite simple. I will include it here. |
UPDATE: turns out it's not that simple 😂. The context approach for the emoji picker won't work for the context menu This is because the context menu ( Lines 183 to 189 in 820fa93
I think the proposal here that moves the emoji picker to Expensify.js is the only way. So, let's handle the emoji picker in that issue. |
@bernhardoj Yeah no problem, I had already considered that, which is why I asked for confirmation. 😅 Next step is updating the Reaction list test , Going back from thread is the bug , so we should consider that. |
Emm, what update exactly needs to be done in the test step? |
This part
This will fail, if we navigate back from thread. I suggest another steps
|
Sorry, I don't get what you mean by "fail". Btw, the test step we have is the correct one. The new test step you gave will just work well in prod because it's not the bug. The bug is when you go back from the thread. |
The test step is confusing me and will confuse the QA , so let's update it and make it clear
which emoji reaction are you referring to ? |
I think we should include a notice for the QA about the picker bug, it's easy to get confused between emoji reacted list and emoji list (emoji list in the picker) |
Done. |
Reviewer Checklist
Screenshots/VideosWebWeb.movMobile Web - Chrome2-Chrome.movMobile Web - Safari3-Safari.movDesktopDesktop.moviOS5-IOS.movAndroidandroid.mov |
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.
Looks good to me and tests well.
🎀 👀 🎀 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.
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/amyevans in version: 1.3.33-0 🚀
|
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.
few little questions :D
🚀 Deployed to production by https://github.com/thienlnam in version: 1.3.33-4 🚀
|
Details
Editing a message after coming back from a child report will crash the app. It's because the global
flatListRef
is null.Fixed Issues
$ #20847
PROPOSAL: #20847 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
As this PR replaces the code from the reaction list PR here #20739, we also need to test it.
NOTE: there is currently a bug with the emoji picker here #21101
Edit message
Reaction list
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)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)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
Web
edit message
web.edit.mov
reaction list
web.reaction.list.mov
Mobile Web - Chrome
edit message
android.mweb.edit.mov
reaction list
android.mweb.reaction.list.mov
Mobile Web - Safari
edit message
mweb.safari.edit.mov
reaction list
mweb.safari.reaction.list.mov
Desktop
edit message
desktop.edit.mov
reaction list
desktop.reaction.list.mov
iOS
edit message
ios.edit.mov
reaction list
ios.reaction.list.mov
Android
reaction list
android.reaction.list.mov
edit message
android.edit.mov