You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2023-08-02] [$1000] The cursor position is not at the end of the message when editing the welcome message #21523
Go to the room details > settings and select "Welcome Message"
Enter a message and click on "Save"
Once again, click on the welcome message for editing
Expected Result:
The cursor position should be at the end of the message when editing the welcome message
Actual Result:
The cursor is at the start of the message
Workaround:
Can the user still use Expensify without this being fixed? Have you informed them of the workaround?
Platforms:
Which of our officially supported platforms is this issue occurring on?
Android / native
Android / Chrome
iOS / native
iOS / Safari
MacOS / Chrome / Safari
MacOS / Desktop
Version Number: 1.3.32-5 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: Any additional supporting documentation
Please re-state the problem that we are trying to solve in this issue.
The cursor position is not at the end of the message when editing the welcome message
What is the root cause of that problem?
Root cause of the issue is that we have not calculated the cursor position by selection property which by default is at zero. This leads to the rendering of cursor at the beginning when we focus it using the ref.
What changes do you think we should make in order to solve the problem?
First of all we need a state in the component to keep the track of caret position which we can use to update the selection.
We could create a selection state using react hooks like this:
Now we need to set an initial positon of caret from where the cursor will start when open the welcome message dalogue.
For this, we already have a state called welcomeMessage which is storing the previous welcome message received from props. So we can use that to set initial caret position.
Now we have a state object which keeps the initial caret position, so now while editing the welcome message when user clicks anywhere inside the <TextInput/> to change the caret position, we can update our state by using onSelectionChange prop. This way we will always keep track of latest caret position.
And now since we have added a util called focusAndUpdateMultiline, we can directly use that once the transition ends and ref is initialised
Focus mechanism and cursor aren't set on reload because the TextInput is not mounted till the time when we call our focus method.
In order to solve this, we should go for a more logical approach rather than using timeouts.
We should run a side-effect when our <TextInput/> has mounted and for this we can track the changes happening on our inputRef.current object.
useEffect(()=>{if(welcomeMessageInputRef.current){// now focus}},[welcomeMessageInputRef.current]);
What alternative solutions did you explore? (Optional)
We can achieve the similar results by using a callback hook too
Or
In the main solution, we can even omit the ref from dependent array after passing the welcomeMessageInputRef directly to the ref prop
changed the title [-]The cursor position is not at the end of the message when editing the welcome message[/-][+][$1000] The cursor position is not at the end of the message when editing the welcome message[/+]on Jun 30, 2023
changed the title [-][$1000] The cursor position is not at the end of the message when editing the welcome message[/-][+][HOLD for payment 2023-08-02] [$1000] The cursor position is not at the end of the message when editing the welcome message[/+]on Jul 26, 2023
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.45-7 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-08-02. 🎊
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.
External issue reporter
Contributor that fixed the issue
Contributor+ that helped on the issue and/or PR
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:
[@mollfpr] The PR that introduced the bug has been identified. Link to the PR:
[@mollfpr] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
[@mollfpr] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
[@mollfpr] Determine if we should create a regression test for this bug.
[@mollfpr] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
[@sakluger] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
[@mollfpr] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
[@mollfpr] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
The regression test should be enough.
[@mollfpr] Determine if we should create a regression test for this bug.
[@mollfpr] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
On Web/mWeb
Create a room
Go to the room details > settings and select "Welcome Message"
Enter a message and click on "Save"
Once again, click on the welcome message for editing
Verify that the cursor position should be at the end of the message when editing the welcome message
Reload the page
Verify that the cursor position should be at the end of the message when editing the welcome message
On Desktop/Native apps
Create a room
Go to the room details > settings and select "Welcome Message"
Enter a message and click on "Save"
Once again, click on the welcome message for editing
Verify that the cursor position should be at the end of the message when editing the welcome message
@ayazhussain79 I forgot to send you an offer previously, sorry about that! I just sent you a contract through Upwork, please let me know once you have accepted the offer.
Activity
melvin-bot commentedon Jun 25, 2023
Triggered auto assignment to @sakluger (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Jun 25, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)chiragxarora commentedon Jun 25, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
The cursor position is not at the end of the message when editing the welcome message
What is the root cause of that problem?
Root cause of the issue is that we have not calculated the cursor position by selection property which by default is at zero. This leads to the rendering of cursor at the beginning when we focus it using the ref.
App/src/pages/ReportWelcomeMessagePage.js
Lines 69 to 80 in 820fa93
What changes do you think we should make in order to solve the problem?
First of all we need a state in the component to keep the track of caret position which we can use to update the selection.
We could create a selection state using react hooks like this:
Now we need to set an initial positon of caret from where the cursor will start when open the welcome message dalogue.
For this, we already have a state called welcomeMessage which is storing the previous welcome message received from props. So we can use that to set initial caret position.
Now we have a state object which keeps the initial caret position, so now while editing the welcome message when user clicks anywhere inside the
<TextInput/>to change the caret position, we can update our state by usingonSelectionChangeprop. This way we will always keep track of latest caret position.And now since we have added a util called
focusAndUpdateMultiline, we can directly use that once the transition ends and ref is initialised`onEntryTransitionEnd={() => if(inputRef && inputRef.current) focusAndUpdateMultiline(inputRef.current);}
UPDATE: (auto focus on reload)
Focus mechanism and cursor aren't set on reload because the TextInput is not mounted till the time when we call our focus method.
In order to solve this, we should go for a more logical approach rather than using timeouts.
We should run a side-effect when our
<TextInput/>has mounted and for this we can track the changes happening on our inputRef.current object.Final code changes
NOTE: no other proposal proposed this solution till the time of final edit
Updated Results
bandicam.2023-07-03.22-12-29-395.mp4
What alternative solutions did you explore? (Optional)
We can achieve the similar results by using a callback hook too
Or
In the main solution, we can even omit the ref from dependent array after passing the welcomeMessageInputRef directly to the ref prop
sakluger commentedon Jun 27, 2023
@Expensify/design do you think this is a bug? I'm leaning towards yes, but wanted a second opinion.
shawnborton commentedon Jun 27, 2023
Wow, what a find. Yeah, I guess it makes sense that the cursor starts off at the end as opposed to the beginning.
sakluger commentedon Jun 30, 2023
Alright let's do this thing. Adding the external label.
[-]The cursor position is not at the end of the message when editing the welcome message[/-][+][$1000] The cursor position is not at the end of the message when editing the welcome message[/+]melvin-bot commentedon Jun 30, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01c431cd4d3b60ebff
64 remaining items
[-][$1000] The cursor position is not at the end of the message when editing the welcome message[/-][+][HOLD for payment 2023-08-02] [$1000] The cursor position is not at the end of the message when editing the welcome message[/+]melvin-bot commentedon Jul 26, 2023
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Jul 26, 2023
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.45-7 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-08-02. 🎊
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:
As a reminder, here are the bonuses/penalties that should be applied for any External issue:
melvin-bot commentedon Jul 26, 2023
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:
mollfpr commentedon Aug 3, 2023
#18662
https://github.com/Expensify/App/pull/18662/files#r1283428248
The regression test should be enough.
On Web/mWeb
On Desktop/Native apps
sakluger commentedon Aug 4, 2023
Summarizing payouts for this issue:
Bug reporter: @ayazhussain79 $250 (hired on Upwork)
Contributor: @hoangzinh $1000 (hired on Upwork)
Contributor+: @mollfpr $1000 (hired on Upwork)
Upwork job: https://www.upwork.com/jobs/~01c431cd4d3b60ebff
sakluger commentedon Aug 4, 2023
@ayazhussain79 I forgot to send you an offer previously, sorry about that! I just sent you a contract through Upwork, please let me know once you have accepted the offer.
ayazhussain79 commentedon Aug 4, 2023
@sakluger offer accepted, Thank you
sakluger commentedon Aug 4, 2023
Thanks @ayazhussain79!