App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD #37147 RN PR][$2000] iOS - Chat - Cursor in the second and following lines touches the symbols of the previous line

Open kbecciv opened this issue 1 year ago • 124 comments

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:

  1. Open the app
  2. Sign in with any account
  3. Go to any chat
  4. Type anything on the composer until you reach the end of the line

Expected Result:

Cursor in the second and following lines NOT touches the symbols of the previous line

Actual Result:

Cursor in the second and following lines touches the symbols of the previous line

Workaround:

UNknown

Platforms:

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

  • [ ] Android / native
  • [ ] Android / Chrome
  • [x] iOS / native
  • [ ] iOS / Safari
  • [ ] MacOS / Chrome / Safari
  • [ ] MacOS / Desktop

Version Number: 1.2.78.0

Reproducible in staging?: Yes

Reproducible in production?: yes

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

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01dac248cbb18d206b
  • Upwork Job ID: 1632682995228594176
  • Last Price Increase: 2023-03-27

kbecciv avatar Mar 03 '23 15:03 kbecciv

Triggered auto assignment to @sakluger (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

MelvinBot avatar Mar 03 '23 15:03 MelvinBot

Bug0 Triage Checklist (Main S/O)

  • [ ] This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • [ ] This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • [ ] This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • [ ] This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • [ ] I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

MelvinBot avatar Mar 03 '23 15:03 MelvinBot

I was able to reproduce, this happens for letters that extend below the line (like p and g). In the screenshot below, you can see that the cursor slightly overlaps with the g from the line above.

IMG_08377C094FCA-1

sakluger avatar Mar 06 '23 10:03 sakluger

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

MelvinBot avatar Mar 06 '23 10:03 MelvinBot

Current assignee @sakluger is eligible for the External assigner, not assigning anyone new.

MelvinBot avatar Mar 06 '23 10:03 MelvinBot

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

MelvinBot avatar Mar 06 '23 10:03 MelvinBot

Triggered auto assignment to @alex-mechler (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

MelvinBot avatar Mar 06 '23 10:03 MelvinBot

Proposal

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

[iOS] Chat: The cursor of the composer is located at the wrong line when touched.

What is the root cause of that problem?

React Native's TextInput component has an issue on iOS regarding the line height - https://github.com/facebook/react-native/issues/28012

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

We can fix it by just removing the lineHeight property in the styles.

shaunnewsum2020 avatar Mar 07 '23 01:03 shaunnewsum2020

📣 @shaunnewsum2020! 📣

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. 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.
  2. 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.
  3. 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>

MelvinBot avatar Mar 07 '23 01:03 MelvinBot

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01619249d793a96491

shaunnewsum2020 avatar Mar 07 '23 01:03 shaunnewsum2020

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

MelvinBot avatar Mar 07 '23 01:03 MelvinBot

Still waiting for more proposals Melvin

alex-mechler avatar Mar 08 '23 22:03 alex-mechler

@alex-mechler This seems to be something that is the default behaviour on RN Text input for iOS. It is not dependent on the line height of the input. I have created a Snack for you to confirm this. I think we should do nothing here.

Screenshot 2023-03-12 at 4 39 09 AM

allroundexperts avatar Mar 11 '23 23:03 allroundexperts

Not overdue, waiting for proposals!

Santhosh-Sellavel avatar Mar 13 '23 16:03 Santhosh-Sellavel

Proposal

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

iOS - Chat - Cursor in the second and following lines touches the symbols of the previous line

What is the root cause of that problem?

React Native's TextInput component has an issue on iOS regarding the line height. The height of the cursor becomes the same as the line height. So touches the previous line.

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

We can fix it by overriding caretRectForPosition function and then changing the height of the cursor for IOS for multiline input.

#pragma mark - Caret Manipulation
- (CGRect)caretRectForPosition:(UITextPosition *)position
{
  if (_caretHidden) {
    return CGRectZero;
  }

  CGRect rect = [super caretRectForPosition:position];
  UIFont *font = self.font;
  rect.size.height = font.pointSize - font.descender;
  rect.origin.y -= font.descender;
  return rect;
}

UI after applying the above code

Screenshot 2023-03-14 at 1 57 27 AM

What alternative solutions did you explore? (Optional)

None

soumyajit4419 avatar Mar 13 '23 20:03 soumyajit4419

📣 @soumyajit4419! 📣

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. 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.
  2. 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.
  3. 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>

MelvinBot avatar Mar 13 '23 20:03 MelvinBot

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01976dd3e633071039

soumyajit4419 avatar Mar 13 '23 20:03 soumyajit4419

⚠️ Missing/invalid email or upwork profile link. Please make sure you add both your Expensify email and Upwork profile link in the format specified.

MelvinBot avatar Mar 13 '23 20:03 MelvinBot

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01976dd3e633071039

soumyajit4419 avatar Mar 13 '23 20:03 soumyajit4419

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

MelvinBot avatar Mar 13 '23 20:03 MelvinBot

@alex-mechler This seems to be something that is the default behaviour on RN Text input for iOS. It is not dependent on the line height of the input. I have created a Snack for you to confirm this. I think we should do nothing here.

@allroundexperts Even if it is the default behavior, it is still a display issue. We should fix this regardless of if it is a default behavior.

alex-mechler avatar Mar 14 '23 16:03 alex-mechler

@soumyajit4419 What's the logic beyond adding 4 to originalRect.origin.y in CGRect computation? Also, can you spin up a PR against RN Upstream, so let's hear thoughts from the RN maintainers too?

Santhosh-Sellavel avatar Mar 15 '23 13:03 Santhosh-Sellavel

@soumyajit4419 What's the logic beyond adding 4 to originalRect.origin.y in CGRect computation? Also, can you spin up a PR against RN Upstream, so let's hear thoughts from the RN maintainers too?

We are decreasing the height of the original react. But its origin.y starts from top . So to bring it down I have added y + 4. So that it stays in the correct position.

I have also created a PR in react-native repository:- https://github.com/facebook/react-native/pull/36484

soumyajit4419 avatar Mar 15 '23 16:03 soumyajit4419

@sakluger @alex-mechler @Santhosh-Sellavel 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!

MelvinBot avatar Mar 17 '23 18:03 MelvinBot

We reduce the height of caret based on the font

- (CGRect)caretRectForPosition:(UITextPosition *)position
{
  if (_caretHidden) {
    return CGRectZero;
  }

  CGRect originalRect = [super caretRectForPosition:position];
    UIFont *font = self.font;
    originalRect.size.height = font.pointSize - font.descender;
    return CGRectMake(originalRect.origin.x, originalRect.origin.y - font.descender , originalRect.size.width, originalRect.size.height);
}

This solution is based on the comments of the react-native PR. I have also updated my upstream PR.

soumyajit4419 avatar Mar 19 '23 18:03 soumyajit4419

Cool let's wait for a review there, Resolve conflicts on the PR too. Can you share your recording to see how it looks now?

Santhosh-Sellavel avatar Mar 19 '23 18:03 Santhosh-Sellavel

Cool let's wait for a review there, Resolve conflicts on the PR too. Can you share your recording to see how it looks now?

I have resolved the conflict in the PR. I have attached the recordings below

https://user-images.githubusercontent.com/46092576/226199938-78400fe7-1f25-4522-8ab9-b312c1197d5b.mov

soumyajit4419 avatar Mar 19 '23 18:03 soumyajit4419

Thanks, LGTM, let's wait for the review!

Santhosh-Sellavel avatar Mar 19 '23 18:03 Santhosh-Sellavel

Proposal

Updated

I have updated the proposal based on react-native PR comments.

soumyajit4419 avatar Mar 20 '23 15:03 soumyajit4419

@Santhosh-Sellavel
The react-native PR is approved PR Can you please check it.

soumyajit4419 avatar Mar 21 '23 16:03 soumyajit4419