App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment 2024-12-17] [HOLD for facebook/react-native#46411[$250] iOS - Chat - Composer not auto scrolled to the bottom when editing message with 10 line breaks

Open lanitochka17 opened this issue 1 year ago • 45 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.25-8 Reproducible in staging?: Y Reproducible in production?: N If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4895266 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause - Internal Team

Action Performed:

  1. Launch New Expensify app
  2. Navigate to a DM
  3. Send a message with 10 line breaks
  4. Edit the message

Expected Result:

Compose box should be auto scrolled to the bottom of the message, the end of the message should be visible. Cursor should be placed at the end of the message

Actual Result:

Compose box is not auto scrolled to the end of the message, 6th is the last line visible to the user

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • [ ] Android: Native
  • [ ] Android: mWeb Chrome
  • [x] iOS: Native
  • [ ] iOS: mWeb Safari
  • [ ] MacOS: Chrome / Safari
  • [ ] MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/user-attachments/assets/b88133ed-09cc-4e08-9944-01fc889c14ab

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01c809bc476538a5ae
  • Upwork Job ID: 1828571296040895701
  • Last Price Increase: 2024-09-24
  • Automatic offers:
    • shubham1206agra | Reviewer | 104134700
    • dominictb | Contributor | 104134702
Issue OwnerCurrent Issue Owner: @VictoriaExpensify

lanitochka17 avatar Aug 27 '24 20:08 lanitochka17

Triggered auto assignment to @deetergp (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

melvin-bot[bot] avatar Aug 27 '24 20:08 melvin-bot[bot]

:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

github-actions[bot] avatar Aug 27 '24 20:08 github-actions[bot]

Production:

https://github.com/user-attachments/assets/6c7611c7-712d-4811-843e-fea58714c94d

lanitochka17 avatar Aug 27 '24 20:08 lanitochka17

Nothing in the deploy checklist jumps out at me as the cause of this. But I also think it isn't significant enough to block on, so I am going to remove the blocker label, set to Daily, and make it External.

deetergp avatar Aug 27 '24 23:08 deetergp

Job added to Upwork: https://www.upwork.com/jobs/~01c809bc476538a5ae

melvin-bot[bot] avatar Aug 27 '24 23:08 melvin-bot[bot]

Triggered auto assignment to Contributor-plus team member for initial proposal review - @shubham1206agra (External)

melvin-bot[bot] avatar Aug 27 '24 23:08 melvin-bot[bot]

Triggered auto assignment to @VictoriaExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

melvin-bot[bot] avatar Aug 27 '24 23:08 melvin-bot[bot]

@MrRefactor @WoLewicki Can you please look into this?

shubham1206agra avatar Aug 28 '24 01:08 shubham1206agra

📣 @bigshoesdev! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Aug 28 '24 02:08 melvin-bot[bot]

Proposal

Please re-state the problem that we are trying to solve in this issue.

iOS - Chat - Composer not auto scrolled to the bottom when editing message with 10 line breaks

What is the root cause of that problem?

We do not wrap the compose text input inside the ScrollView and we do not auto scroll to the end inside the input

What changes do you think we should make in order to solve the problem?

We can wrap the compose input inside the ScrollView and link the ScrollView to useRef and invoke the scrollEnd function scrollViewRef.current?.scrollToEnd({ animated: true })

What alternative solutions did you explore? (Optional)

NJ-2020 avatar Aug 28 '24 14:08 NJ-2020

Proposal

Please re-state the problem that we are trying to solve in this issue.

Compose box is not auto scrolled to the end of the message, 6th is the last line visible to the user

What is the root cause of that problem?

This issue happen on native TextInput in iOS, but not Android. The reason is because in Android, when we set autoFocus=true or when we call focus() command from React, internall RN will call this function requestFocusInternal here, and due to this call, the AppCompatEditText will scroll down to show the current text editor selection into view. Read more in here

Unfortunately, we don't have the same mechanism in the iOS. We only call becomeFirstResponder for the TextView when calling focus() command programmtically or when autoFocus=true here

What changes do you think we should make in order to solve the problem?

Based on this: https://github.com/facebook/react-native/pull/38679/, we can add a function in RCTTextInputComponentView.mm

- (void)scrollCursorIntoView {
    // Assuming you have a UITextView or similar text input view
    UITextRange *selectedRange = _backedTextInputView.selectedTextRange;
    // Updating the UITextView attributedText, for example changing the lineHeight, the color or adding
    // a new paragraph with \n, causes the cursor to move to the end of the Text and scroll.
    // This is fixed by restoring the cursor position and scrolling to that position (iOS issue 652653).
    if (selectedRange.empty) {
      // Maintaining a cursor position relative to the end of the old text.
      NSInteger offsetStart = [_backedTextInputView offsetFromPosition:_backedTextInputView.beginningOfDocument
                                                            toPosition:selectedRange.start];
      [_backedTextInputView scrollRangeToVisible:NSMakeRange(offsetStart, 0)];
    }
}

And add the calls when the text view is being auto focused or focused programmatically here

....
   [_backedTextInputView becomeFirstResponder];
   [self scrollCursorIntoView];
....

What alternative solutions did you explore? (Optional)

dominictb avatar Aug 30 '24 10:08 dominictb

Asked for 2nd opinion here https://expensify.slack.com/archives/C066HJM2CAZ/p1725018537186099

shubham1206agra avatar Aug 30 '24 11:08 shubham1206agra

@dominictb Can you create an upstream PR to fix this?

shubham1206agra avatar Aug 30 '24 16:08 shubham1206agra

@deetergp, @VictoriaExpensify, @shubham1206agra Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] avatar Sep 02 '24 18:09 melvin-bot[bot]

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

melvin-bot[bot] avatar Sep 03 '24 16:09 melvin-bot[bot]

@shubham1206agra sure, let me raise the upstream PR.

dominictb avatar Sep 04 '24 12:09 dominictb

@deetergp, @VictoriaExpensify, @shubham1206agra Huh... This is 4 days overdue. Who can take care of this?

melvin-bot[bot] avatar Sep 04 '24 18:09 melvin-bot[bot]

Not overdue - @dominictb is working on a PR

VictoriaExpensify avatar Sep 04 '24 23:09 VictoriaExpensify

This is just a pure chat bug, moving to #vip-vsb.

trjExpensify avatar Sep 10 '24 01:09 trjExpensify

PR: https://github.com/facebook/react-native/pull/46411

dominictb avatar Sep 10 '24 08:09 dominictb

@dominictb I think you need to repro this issue on react-native test app. And file this as bug there too.

shubham1206agra avatar Sep 10 '24 09:09 shubham1206agra

Alright, I'll file an issue in the upstream repo. I could reproduce the bug in the their example app.

dominictb avatar Sep 10 '24 13:09 dominictb

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

melvin-bot[bot] avatar Sep 10 '24 16:09 melvin-bot[bot]

@deetergp @VictoriaExpensify @shubham1206agra this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

melvin-bot[bot] avatar Sep 10 '24 17:09 melvin-bot[bot]

Since this is an upstream bug and out of our control, I'm going to demote it to weekly and check back at that cadence.

deetergp avatar Sep 10 '24 18:09 deetergp

Thanks for filing the bug @dominictb. Can you link it here?

deetergp avatar Sep 10 '24 18:09 deetergp

Hmm, I'm not sure we need to file an issue in the upstream repo. I take a look at this PR https://github.com/facebook/react-native/pull/38679 and it doesn't link to any github issue. Also check the contributing guideline there and saw no requirement of creating issue before submitting PR

However, I added some more reproduction steps and video here, hoping that it is clearer for the reviewer. Let's wait for their feedback then.

dominictb avatar Sep 11 '24 11:09 dominictb

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

melvin-bot[bot] avatar Sep 17 '24 16:09 melvin-bot[bot]

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

melvin-bot[bot] avatar Sep 24 '24 16:09 melvin-bot[bot]

@shubham1206agra @deetergp can I get assigned here? My PR is being reviewed by the Meta team. Thank you!

dominictb avatar Sep 24 '24 17:09 dominictb