-
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
[HOLD for payment 2023-08-02] [$1000] The cursor position is not at the end of the message when editing the welcome message #21523
Comments
Triggered auto assignment to @sakluger ( |
Bug0 Triage Checklist (Main S/O)
|
ProposalPlease 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. const [selection, setSelection] = useState({start: n, end: n}); Now we need to set an initial positon of caret from where the cursor will start when open the welcome message dalogue. 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 And now since we have added a util called `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. We should run a side-effect when our useEffect(() => {
if(welcomeMessageInputRef.current) {
// now focus
}
}, [welcomeMessageInputRef.current]); Final code changes function ReportWelcomeMessagePage(props) {
...................
useEffect(() => {
if(welcomeMessageInputRef.current) {
focusAndUpdateMultilineInputRange(welcomeMessageInputRef.current);
}
}, [welcomeMessageInputRef.current]);
...................
<TextInput
inputID="welcomeMessage"
label={props.translate('welcomeMessagePage.welcomeMessage')}
multiline
numberOfLines={10}
maxLength={CONST.MAX_COMMENT_LENGTH}
ref={(el) => (welcomeMessageInputRef.current = el)}
value={welcomeMessage}
onChangeText={handleWelcomeMessageChange}
autoCapitalize="none"
textAlignVertical="top"
/> NOTE: no other proposal proposed this solution till the time of final edit Updated Resultsbandicam.2023-07-03.22-12-29-395.mp4What alternative solutions did you explore? (Optional)We can achieve the similar results by using a callback hook too |
@Expensify/design do you think this is a bug? I'm leaning towards yes, but wanted a second opinion. |
Wow, what a find. Yeah, I guess it makes sense that the cursor starts off at the end as opposed to the beginning. |
Alright let's do this thing. Adding the external label. |
Job added to Upwork: https://www.upwork.com/jobs/~01c431cd4d3b60ebff |
Current assignee @sakluger is eligible for the External assigner, not assigning anyone new. |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @mollfpr ( |
ProposalPlease 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?In the focus logic when the Report welcome message loaded, we just call App/src/pages/ReportWelcomeMessagePage.js Lines 51 to 56 in 0bbf3fc
It seems we forgot to set selection range to make the cursor position when the message has value like other places. I.e: What changes do you think we should make in order to solve the problem?We can't do same things we did for Workspace invite message page here because when we visit by direct link, although So my approach is: Code referenceconst useFocusInputRangeWhenReady = (inputRef) => {
const [isInputRefReady, setIsInputRefReady] = useState(false);
const [didInputTransitionEnd, setDidInputTransitionEnd] = useState(false);
useEffect(() => {
if (!isInputRefReady || !didInputTransitionEnd) {
return;
}
focusAndUpdateMultilineInputRange(inputRef.current);
}, [isInputRefReady, didInputTransitionEnd, inputRef]);
return { setIsInputRefReady, setDidInputTransitionEnd}
}
onEntryTransitionEnd={() => {
setDidInputTransitionEnd(true);
}}
ref={(el) => {
welcomeMessageInputRef.current = el;
setIsInputRefReady(Boolean(welcomeMessageInputRef.current));
}} Recording resultScreen.Recording.2023-07-10.at.18.30.40.movWhat alternative solutions did you explore? (Optional)Alternative 1:
So need to put focus code in 2 places, and ensure in each place, the 2 conditions above match:
if (!welcomeMessageInputRef.current && el && didScreenTransitionEnd) {
focusAndUpdateMultilineInputRange(el);
} Alternative 2: We will use above util and replace for this line here |
I investigated the issue. Seems to be the expected behaviour of react-navigation.
https://reactnavigation.org/docs/navigation-lifecycle/#example-scenario |
Looks like something related to As a reminder, please make sure that all proposals are not workarounds and that any and all attempt to fix the issue holistically have been made before proceeding with a solution. Proposals to change our Feel free to drop a note in #expensify-open-source with any questions. |
Not overdue, still looking at proposals. |
@chiragxarora It has the same result as using @hoangzinh The input needs to be focused after refreshing the page. |
Actually at the time I wrote the proposal, this |
This comment was marked as outdated.
This comment was marked as outdated.
I've updated my proposal #21523 (comment) too for the reloading case, pls check @mollfpr |
@mollfpr I just updated my proposal #21523 (comment) to cover the case that you mentioned above. |
I just tested on staging and confirmed that this bug is still reproduceable. @danieldoglas do you agree that we should assign @hoangzinh? |
📣 @mollfpr 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @hoangzinh 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Upwork job |
📣 @ayazhussain79 We're missing your Upwork ID to automatically send you an offer for the Reporter role. |
Yep, #22586 is unrelated to this issue, so we should continue with the triage process. |
@mollfpr @danieldoglas Thanks for accepting my proposal. The PR is ready #23162. Please help me review it. Thanks |
This one just got merged, thanks everyone! Looks like it was merged in 4 business days. |
|
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:
|
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:
|
https://github.com/Expensify/App/pull/18662/files#r1283428248
The regression test should be enough.
On Web/mWeb
On Desktop/Native apps
|
Summarizing payouts for this issue: Bug reporter: @ayazhussain79 $250 (hired on Upwork) Upwork job: https://www.upwork.com/jobs/~01c431cd4d3b60ebff |
@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. |
@sakluger offer accepted, Thank you |
Thanks @ayazhussain79! |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
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?
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
screen-recording-2023-06-20-at-24757-pm_rWeBf4YW.mp4
Recording.5122.mp4
Expensify/Expensify Issue URL:
Issue reported by: @ayazhussain79
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1687255221337649
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: