-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[HOLD for payment 2023-12-12] [$500] mWeb/Safari- Chat - Focus is in the start of the message when opening a report with a draft message #31708
Comments
Triggered auto assignment to @conorpendergrast ( |
Job added to Upwork: https://www.upwork.com/jobs/~01fc3a996f2399bc80 |
Bug0 Triage Checklist (Main S/O)
|
Triggered auto assignment to Contributor-plus team member for initial proposal review - @burczu ( |
@izarutskaya Not reproducible on latest main |
ProposalPlease re-state the problem that we are trying to solve in this issue.For mobile Safari, when a draft message is opened, the cursor is at the beginning of the message instead of the end. What is the root cause of that problem?The only time we don't set the initial selection is for mobile Safari if App/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.js Lines 130 to 138 in f1e085b
But we're not using App/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.js Lines 58 to 60 in f1e085b
What changes do you think we should make in order to solve the problem?Remove the conditionals from the initial selection state - we should always set it. It won't have impact if the the composer isn't focused, so any dependency between autofocus logic and initial selection state is just added complexity. const [selection, setSelection] = useState({ start: value.length, end: value.length }) |
ProposalPlease re-state the problem that we are trying to solve in this issue.If we have a composer draft in a chat with existing messages and reopen that chat, the composer will auto-focus and put the cursor at the front of the input text. What is the root cause of that problem?When we open a chat with existing messages on a mobile screen, the autofocus shouldn't work (it fails on App/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.js Line 130 in 704f3f7
And if autofocus is false, we will set the input selection to 0, only on Safari. App/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.js Lines 135 to 138 in 704f3f7
It is added in this PR #19293 to fix #15105. The reason we want to set it to 0 if autofocus is false is because if we set it to > 0, the input will be autofocused regardless of the autofocus attribute and we want to avoid that. The selection here is 0 and we pass it to App/src/components/Composer/index.js Lines 176 to 179 in 704f3f7
Thus, the composer is autofocused. Then, we have a App/src/components/Composer/index.js Lines 193 to 200 in 704f3f7
In our case, the There is also another code that caused the unwanted autofocus. App/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.js Lines 511 to 513 in 704f3f7
The code above will (run on mount) set the selection to the end of the composer and scroll the composer to the bottom. This means we have 2 selection logic, 1 with the fix of #15105 (with a state), and 1 without the fix (with a native method). That's why the composer is always autofocused and the selection is at the start of the text. What changes do you think we should make in order to solve the problem?First, we should move the mWeb Safari fix to const shouldSetSelection = !(Browser.isMobileSafari() && !shouldAutoFocus);
if (shouldSetSelection) {
input.setSelectionRange(length, length);
} Now, update the const [selection, setSelection] = useState(() => ({start: 0, end: 0})); Next, initialize the const [selection, setSelection] = useState({
start: selectionProp.start,
end: selectionProp.end,
}); This will make sure the input won't be autofocused when it shouldn't (the real issue) on mWeb Safari but the input is still scrolled to the bottom. |
I have reproduced on iOS, in Safari 👍 |
@conorpendergrast, @burczu Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
Not overdue, I'll be reviewing this issue soon. |
First of all, I've checked how this works on Android mWeb and it does not focus the input when we get back to the chat that is in edit mode, so I think this is the expected behaviour of this issue (not putting the cursor at the end, just not focusing the input at all). That being said, the solution from @bernhardoj solves the issue this way and make the app on iOS and Android mWeb working consistently, so I believe we should proceed with it. The solution from @erquhart indeed moves the cursor at the end, but only on iOS and does not change the behaviour on Android so the outcome is inconsistent on both devices. 🎀 👀 🎀 C+ reviewed |
Triggered auto assignment to @dangrous, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
This sounds good to me! That conditional ( |
📣 @bernhardoj 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
PR is ready cc: @burczu |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.7-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2023-12-12. 🎊 After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
For reference, here are some details about the assignees on this issue:
|
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
n/a
I'm not sure about regression test here - it didn't block the App from being usable, it was just a small inconvenience only in one of the environments we support.
|
@burczu This was a bug identified by Applause, so we likely don't need a new regression test. Thanks! |
Payouts due:
Upwork job is here. |
All done, thanks everyone |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Issue found when executing PR: #31295
Version Number: 1.4.2-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
Expensify/Expensify Issue URL:
Issue reported by: Applause-Internal Team
Slack conversation: @
Action Performed:
Expected Result:
The focus is on the end of the message so user can continue typing
Actual Result:
The focus is on the start of the message. User needs to manually move the cursor to the end to continue
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Bug6287152_1700658449599.RPReplay_Final1700650930.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: