Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.53k stars 2.88k forks source link

[HOLD for payment 2023-10-09] [$1000] Quoting macOS Download Link with text will result in unexpected behaviour #23672

Closed kavimuru closed 1 year ago

kavimuru commented 1 year ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Open the app in Android native app (this issue only occurs in Android native)
  2. Go to any chat
  3. Type a message:> https://new.expensify.com/NewExpensify.dmg test
  4. Send it

Expected Result:

All characters should be visible

Actual Result:

The end characters will not be visible

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.46-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

https://github.com/Expensify/App/assets/43996225/7330f977-7909-4029-be8c-4e1f14569fe1 Screenshot_20230726-134920_New Expensify

Expensify/Expensify Issue URL: Issue reported by: @daraksha-dk Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1690296200318199

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e4f40b6933ecb982
  • Upwork Job ID: 1686407694784102400
  • Last Price Increase: 2023-09-08
  • Automatic offers:
    • abdulrahuman5196 | Reviewer | 26853127
    • pradeepmdk | Contributor | 26853130
    • daraksha-dk | Reporter | 26853132
melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

Bug0 Triage Checklist (Main S/O)

sakluger commented 1 year ago

Asked a few clarifying questions in the Slack thread

melvin-bot[bot] commented 1 year ago

@sakluger Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

sakluger commented 1 year ago

Confirmed in Slack that this is only happening in the Android app for this specific download link, so it's a pretty specific but that likely won't occur often. But it's possible that it affects other scenarios, so I think we should fix it.

melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

@sakluger, @abdulrahuman5196 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

sakluger commented 1 year ago

Huh, no proposals at all! Let's give it another week and see if we get any proposals at this price.

sakluger commented 1 year ago

Still waiting for proposals.

Krishna2323 commented 1 year ago

Proposal

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

Quoting macOS Download Link with text will result in unexpected behaviour

What is the root cause of that problem?

The issue seems specific to android and how react-native-render-html renders html & this is caused by applying flex-start to every View component used in custom renderer.

  1. In Flexbox, the default alignment for alignItems is stretch, which means child items will stretch to fill the container's height. When you specify flex-start, items don't stretch, and they are placed at the start of the container's cross-axis. This might cause text to clip if there's not enough space.
  2. React Native is not free of bugs. It's possible that it has a bug related to alignItems on Android.
  3. Android and iOS render fonts differently. It's possible that on Android, the font metrics cause the text to need slightly more space than its container provides when flex-start is used.
  4. Android might interpret dimensions, margins, paddings, or borders differently than iOS, which could lead to different layouts and consequently the text clipping issue.

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

Solution 1

We can just remove styles.alignItemsStart from here & it will solve the problem. We can check if it has any effect on other elements and safely remove if no side effect found.

https://github.com/Expensify/App/blob/d6a14d797753e8b7886b3c85a4450ff9cdd6e6be/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js#L51

Solution 2

Sometimes the clipping happens because of the difference between device font and font used in the code and this only happens in android so we can use device default font to solve this.

This solution essentially serves as a patch to handle a specific problem in a controlled manner. It's about ensuring that problematic devices use device default font that doesn't lead to clipping in React Native.

export default function enableAndroidFontFix() {
    if (Platform.OS !== 'android') {
        return;
    }
    const styles = StyleSheet.create({
        androidFontFixFontFamily: {
            fontFamily: fontFamily.SYSTEM,
        },
    });

    const oldRender = Text.render;
    Text.render = function (...args) {
        const origin = oldRender.call(this, ...args);
        return React.cloneElement(origin, {
            style: [styles.androidFontFixFontFamily, origin.props.style],
        });
    };
}

Result:

https://github.com/Expensify/App/assets/85894871/c083b594-e424-4393-ab70-58f763421540

melvin-bot[bot] commented 1 year ago

📣 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] commented 1 year ago

📣 @alex2bc! 📣 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>
melvin-bot[bot] commented 1 year ago

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

Krishna2323 commented 1 year ago

@sakluger, this issue also occurs on other links and it also occurs without blockquote.

https://github.com/Expensify/App/assets/85894871/91b9ae1f-cafe-4f05-a313-9a6cb5d07689

melvin-bot[bot] commented 1 year ago

@sakluger @abdulrahuman5196 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!

sakluger commented 1 year ago

this issue also occurs on other links and it also occurs without blockquote.

@Krishna2323 thanks, that's helpful! Were you able to determine why it happens for some links but not others?

@abdulrahuman5196, mind taking a look at the two proposals we received?

Krishna2323 commented 1 year ago

@sakluger, the text clipping only happens in android native and the issue is related to custom renderers used in the code.

I observed this issue occurs when a link is broken into multiple line and the last link line has just enough space for the text.

WhatsApp Image 2023-08-10 at 04 51 39

alex2bc commented 1 year ago

Updated proposal to include fix of 2 found issues

Krishna2323 commented 1 year ago

@alex2bc, the margin on the right isn't causing the bug.

alex2bc commented 1 year ago

@Krishna2323, it is an issue and causing inconsistent rendering of html blockquote element compared to other messages. Due to that blockquote link is shrank.

Krishna2323 commented 1 year ago

@alex2bc, I mean it can be an issue but it's not related to clipping of text.

alex2bc commented 1 year ago

@Krishna2323 yeap, I agree

pradeepmdk commented 1 year ago

Proposal

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

Quoting macOS Download Link with text will result in unexpected behaviour

What is the root cause of that problem?

dude to android textbreakstrategy its breaking ex: here and here Screenshot 2023-08-01 at 8 17 50 AM

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

https://github.com/Expensify/App/blob/d6a14d797753e8b7886b3c85a4450ff9cdd6e6be/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js#L60

    const defaultTextProps = useMemo(() => ({selectable: props.textSelectable, allowFontScaling: false, textBreakStrategy: "simple", }), [props.textSelectable]);

pass textBreakStrategy: "simple",

Result:

Screenshot 2023-08-10 at 9 17 50 PM
sakluger commented 1 year ago

@abdulrahuman5196 can you take a look at the proposals we've received so far? If you already have a full plate, I'm happy to reassign.

abdulrahuman5196 commented 1 year ago

I am reviewing all my pending items this weekend. Will close review on this as well

abdulrahuman5196 commented 1 year ago

I am not sure what is the issue here, for me it seems to be working fine. Anything I am missing here. @sakluger

https://github.com/Expensify/App/assets/46707890/e6d786d6-24e5-4efa-b9fc-44483a8359a9

Krishna2323 commented 1 year ago

@abdulrahuman5196, your emulator screen width is enough for this specific link, try increasing the link like I did here.

melvin-bot[bot] commented 1 year ago

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

mvtglobally commented 1 year ago

Issue not reproducible during KI retests. (First week)

sakluger commented 1 year ago

Looks like this is not longer reproduceable, I'm going to close the issue. Feel free to comment on the original thread if you're able to reproduce on the latest build.

Krishna2323 commented 1 year ago

@sakluger, can we reopen this, I'm still able to reproduce it on my physical device. Version: 1.3.55-8

sakluger commented 1 year ago

Opening this back up because several contributors were able to reproduce on the latest build.

pradeepmdk commented 1 year ago

@sakluger can you review my proposal https://github.com/Expensify/App/issues/23672#issuecomment-1673491181 and here i am attaching the reference ticket https://github.com/meliorence/react-native-render-html/issues/360#issuecomment-761612982

melvin-bot[bot] commented 1 year ago

📣 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] commented 1 year ago

@sakluger, @abdulrahuman5196 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

abdulrahuman5196 commented 1 year ago

I will try to repro the issue again and update here

sakluger commented 1 year ago

@pradeepmdk I cannot review proposals as I am not an engineer. I'm mainly here to make sure the issue keeps moving forward :)

sakluger commented 1 year ago

@abdulrahuman5196 any luck reproducing?

melvin-bot[bot] commented 1 year ago

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

sakluger commented 1 year ago

@Krishna2323 can you write out the reproduction steps? Especially if they're different than the original steps, I want to make sure that @abdulrahuman5196 can also reproduce.

Krishna2323 commented 1 year ago

@sakluger, these Steps is enough to reproduce it, I can easily reproduce it on my physical device and pixel 3a simulator.

Krishna2323 commented 1 year ago

@abdulrahuman5196, we can update flex-start to flex-stretch because if we don't do it, we will face other issues as well.

Issue: If we set flex-start to all containers, then we can't select all text by clicking on empty spaces.

https://github.com/Expensify/App/assets/85894871/6cc54745-e98a-4308-879c-e39a0f0a7a5b

abdulrahuman5196 commented 1 year ago

Oh ok got it. I was able to reproduce by following this https://github.com/Expensify/App/issues/23672#issuecomment-1672307199.

It is a very strange issue. Could you kindly add this information to the OP description @sakluger

abdulrahuman5196 commented 1 year ago

And @Krishna2323 Kindly add all the information in your original proposal https://github.com/Expensify/App/issues/23672#issuecomment-1668714244 and mentioning Updated proposal in comment as per our guidelines should be enough. It will be easier to manage and to make sure we don't miss anything.

Krishna2323 commented 1 year ago

@abdulrahuman5196, I already have that in my proposal, I just wanted to tell that it also solves other issues as well.

abdulrahuman5196 commented 1 year ago

@Krishna2323 's proposal (solution 1) here https://github.com/Expensify/App/issues/23672#issuecomment-1668714244 and @pradeepmdk 's proposal here https://github.com/Expensify/App/issues/23672#issuecomment-1673491181 is both working well.

But I not convinced on the root cause provided. @Krishna2323 , @pradeepmdk Could you kindly add more information or references on why this issue is coming? Is it due to bug in react-native-render-html or some other bug? Do we have any open GH against the repo or the RN repo?

Krishna2323 commented 1 year ago

@abdulrahuman5196, this is a react-native bug, nothing to do with react-native-render-html .

Krishna2323 commented 1 year ago

@abdulrahuman5196, Setting textBreakStrategy to simple on the Text element seems to work for some devices like Samsung galaxy s10, Google Pixel but it will not work on all devices, many users still face text clip issue, specially on some devices like Oppo, OnePlus and more.