Closed kavimuru closed 7 months ago
Triggered auto assignment to @miljakljajic (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details.
Platforms
in OP are ✅)@miljakljajic Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
@miljakljajic Still overdue 6 days?! Let's take care of this!
I am not able to reproduce this - I believe it may have been resolved while I was OOO.
@miljakljajic I still can reproduce on staging web
It seems @miljakljajic is not available during this time. @kavimuru Could you reproduce this issue?
This has also been reported here on mac web (chrome), but I was unable to reproduce it on v1.2.92-0 on the staging version. @gadhiyamanan, before this one gets reopened, could you please test on the app version v1.2.92-0 and confirm it's reproducible?
@kadiealexander I can reproduce it with the latest version v1.2.92-0
This has also been reported here on mac web (chrome), but I was unable to reproduce it on v1.2.92-0 on the staging version. @gadhiyamanan, before this one gets reopened, could you please test on the app version v1.2.92-0 and confirm it's reproducible?
@kadiealexander assuming you might have used enter to send message but to reproduce you need to click on send button.
Ok, tested on Pixel 3a (v 92-0) and I can reproduce:
to reproduce you need to click on send button.
Yep, that's what I did - clicked on the button
Thanks for that tip @Pujan92, I was able to repro on mac web chrome:
Thank you for reproducing! Do we think this could be worked on externally? Adding engineering label to confirm
Triggered auto assignment to @MonilBhavsar (Engineering
), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
@miljakljajic @MonilBhavsar this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!
I am able to reproduce. Can be worked externally
Job added to Upwork: https://www.upwork.com/jobs/~01eccf0dd16e54ab9d
Current assignee @miljakljajic is eligible for the External assigner, not assigning anyone new.
Emoji suggestions still shows after send button click
On submitting the comment we are not resetting the emoji suggestions which causes the suggestions are still showing after send button click.
We need to call this.resetSuggestedEmojis()
inside the prepareCommentAndResetComposer
after resetting the comment here.
https://github.com/Expensify/App/blob/8a1510373598807a4ea6c5049f2a3121dfbd9215/src/pages/home/report/ReportActionCompose.js#L625-L633
Triggered auto assignment to Contributor-plus team member for initial proposal review - @s77rt (External
)
Current assignee @MonilBhavsar is eligible for the External assigner, not assigning anyone new.
Emoji suggestion popover still remains after clearing composer input programatically
onSelectionChange
event is not called when input is cleared programmatically.
We calculate emoji suggestion visibility in this function. So when send message, input cleared but popover visibility is not re-calculated.
This is web issue. Works fine on native (onSelectionChange
is called and selection
is updated to {start: 0, end: 0}
).
So the ideal solution is to fix this selection issue on web because after sending message, selection
value will be staled until user focus on input again or type anything.
Solution1: make onSelectionChange
work when clear input in upsream repo
Solution2: call onSelectionChange
manually when input is cleared
Solution3: manually call resetSuggestedEmojis
after reset composer but this is workaround because selection
still remains
Emoji suggestions still remain after sending a message
We have a logic to resetSuggestedEmojis when entering escape
from the keyboard, but we don't do the same when clicking the button so that the emoji suggestions still remain after the button is clicked
This issue is fixed in native because after clicking the send button, onSelectionChange is triggered so that it will re-calculate the emoji suggestion with the empty composer (because the composer is cleared after clicking the send button).
The current flow in native: Click send button > onClear is triggered (the emoji suggestion still remains) > send API > onSelectionChange is triggered (the emoji suggestion disappears). See the below video
We can see that the suggestion doesn't disappear immediately after send button is clicked. I see that if we close the suggestion emoji when onSelectionChange is not suitable and the fix on native currently is a workaround
onClear={() => {
console.log('CLEAR'); // THIS IS LOG IN THE ABOVE VIDEO
this.resetSuggestedEmojis(); // ADD HERE
this.setTextInputShouldClear(false);
}}
We can call this.resetSuggestedEmojis() when onClear is triggered
In ReportActionCompose.js, we should add logic to reset the emoji suggestion by adding resetSuggestedEmojis() function inside prepareCommentAndResetComposer() function. Like this
prepareCommentAndResetComposer() {
const trimmedComment = this.comment.trim();
// Don't submit empty comments or comments that exceed the character limit
if (this.state.isCommentEmpty || ReportUtils.getCommentLength(trimmedComment) > CONST.MAX_COMMENT_LENGTH) {
return '';
}
this.resetSuggestedEmojis(); // ADD HERE
this.updateComment('');
this.setTextInputShouldClear(true);
if (this.props.isComposerFullSize) {
Report.setIsComposerFullSize(this.props.reportID, false);
}
this.setState({isFullComposerAvailable: false});
return trimmedComment;
}
@Pujan92 Thanks for the proposal. I'm afraid your proposal is not eligible for review.
Do not propose solutions to jobs until the Help Wanted label has been applied. Any proposals submitted before these labels are added will not be reviewed.
@situchan Thanks for the proposal. Your RCA is correct. I think we are looking for an upstream fix here. Are you working on a PR for that or can you elaborate your suggested upstream changes?
@dukenv0307 Thanks for the proposal. I don't think the RCA is correct as it does not explain why the bug only occurs on Web and not Native.
@dukenv0307 Thanks for the update. I think what you are suggesting is more like an improvement and does not fix the root cause. I think we should still fix the stale selection
on RNW.
Not overdue. We narrowed the bug to RNW and we are looking for an upstream fix (fix stale selection
on RNW).
@s77rt @miljakljajic @MonilBhavsar this issue is now 4 weeks old and preventing us from maintaining WAQ, can you:
Thanks!
Current assignee @s77rt is eligible for the Internal assigner, not assigning anyone new.
@s77rt could you please provide more details on this https://github.com/Expensify/App/issues/15934#issuecomment-1502086640
@MonilBhavsar Check https://snack.expo.dev/JGFbUc_KU?platform=android
On Android:
On Web:
iOS is having a different behavior, on the Expo Snack it's not working but on E/App it's working, this may be due to other factors. For simplicity let's focus on matching Web behavior with Android behavior.
Current assignee @miljakljajic is eligible for the External assigner, not assigning anyone new.
Current assignee @s77rt is eligible for the External assigner, not assigning anyone new.
Current assignee @MonilBhavsar is eligible for the External assigner, not assigning anyone new.
Thanks for the explanation! I made it external again. Are we still waiting for proposals for upstream fix or it is already being worked on?
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@MonilBhavsar We are still waiting for proposals.
suggestion for Emoji remains even after sending message
To be more clear, the issue is originating from onMouseDown
event handler. When button view is clicked, we are calling
https://github.com/Expensify/App/blob/ee3a27e9de22ca519c0ca6632a2dfee4246d4966/src/pages/home/report/ReportActionCompose/index.js#L924
to keep focus on composer. Although it is keeping focus on composer it is not registering cursor change and not firing onSelectionChange
.
If we try the same thing in react it self it works as expected - https://codesandbox.io/s/quizzical-sutherland-4uwx4?file=/src/index.js
After a long investigation, it looks like it is not possible to fix it in upstream. Basically, this is coming down to how react native handles events, and react native web
's extension on this usage. They are using responder system to manage mouse events. One of the side effect is onMouseDown
event is not passed to dom itself unlike react which passes, and they are handling preventDefault()
differently. Even passing the event to dom manually won't work. There are a lot of things going on in react-native
and react-native-web
to intercept this events and to handle them.
Is it possible to fix responder it self? Well, responder itself is looking pretty complex and has a lot of moving parts, also it is responsible for mainly handling touch based interactions in mobile platforms. One small change might cause whole another wave of side effects which is hard to catch and effect entire app. And I think that fix itself would be some sort of workaround.
The most optimal solution is going to be manually resetting selection when input gets cleared.
This solution might look a hack if we treat not calling selectionChange
when input gets cleared as bug, which is arguable. If we use javascript itself it will only call onSelect
if there is an actual selection - https://codesandbox.io/s/goofy-goldberg-52lys?file=/src/index.js
P. S. According to react-native-web
onSelectionChange
is directly corresponding to onSelect
attribute.
This what the best conclusion I have drawn to summarize my research but still if you have any questions, I am here to answer
@alitoshmatov Thanks for the proposal. At first, I thought this is related to onMouseDown
too, but the fact that the "Fill" button works https://codesandbox.io/s/cocky-grass-xvxqgr tells us there is more. On Web (HTML5) the input's onSelect handler does not track the cursor position. React seems to be implementing its own cursor-tracking logic and that logic is missing the case where the input is programmatically cleared. I think we agree that the bug is even at a lower level which react itself.
That being said I think we are narrowing the bug to react's SelectEventPlugin.
@s77rt I think you missed that onMouseDown
event is applied to outer div and "Fill" button is also inside this div. That's why it is working. And that is expected behavior. Thus, bug is not in react itself.
Correct me if I missed something
@alitoshmatov But the "Clear" button has the same circumstances as "Fill". Yet "Clear" does not work while "Fill" works. Check the sent codesandbox https://codesandbox.io/s/cocky-grass-xvxqgr
@s77rt So there has been a bit misunderstanding between us, and just to make this issue more complex here is a new finding 😅. I have been using firefox and in the example you provided both buttons, including "clear" will reset selection. But in chrome as you said "clear" button is not working
@alitoshmatov That's interesting. I have tried on Webkit/Safari and the issue is not reproducible there. So I think this is probably a bug in Chrome?
@s77rt It might be. But still in react native it is not working in both browsers
@alitoshmatov Right, but we can ignore Firefox as it's not officially supported. On WebKit that works.
@s77rt Yeah, this issue in expensify app is not reproducible in safari.
I am confused
Right, I still think we should investigate why SelectEventPlugin fails on Chrome. Then we can decide if the bug can be fixed on the plugin or it's something related to Chrome.
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Action Performed:
Expected Result:
Suggested emoji should be removed after sending the message
Actual Result:
Emoiji suggestions shows
Workaround:
unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Version Number: 1.2.92-0 Reproducible in staging?: y Reproducible in production?: y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos:
https://user-images.githubusercontent.com/43996225/224875615-cecd9a1d-1424-46f2-b08e-51a0f88da5a2.mp4
Expensify/Expensify Issue URL: Issue reported by: @gadhiyamanan Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1678718820449989
View all open jobs on GitHub
Upwork Automation - Do Not Edit