App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment 2021-12-13] Copy icon is not aligned with text - Reported by: @Santhosh-Sellavel

Open isagoico opened this issue 5 years ago • 47 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. Navigate to a workspace
  2. Click on Reimburse receipts
  3. Check the copy icon next to [email protected]

Expected Result:

Copy icon should be aligned with text.

Actual Result:

Copy icon is not aligned with text.

Workaround:

None needed. Visual issue.

Platform:

Where is this issue occurring?

  • Web
  • iOS
  • Android
  • Desktop App
  • Mobile Web

Version Number: 1.1.7-22

Reproducible in staging?: Yes Reproducible in production?: Yes

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

image

Expensify/Expensify Issue URL:

Issue reported by: @Santhosh-Sellavel Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1634233307289600

View all open jobs on GitHub

isagoico avatar Oct 15 '21 03:10 isagoico

Triggered auto assignment to @AndrewGable (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

MelvinBot avatar Oct 15 '21 03:10 MelvinBot

Triggered auto assignment to @arielgreen (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

MelvinBot avatar Oct 15 '21 05:10 MelvinBot

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

MelvinBot avatar Oct 18 '21 19:10 MelvinBot

Posted to Upwork: https://www.upwork.com/jobs/~0155a00a29d7e8f8cb

arielgreen avatar Oct 19 '21 17:10 arielgreen

@arevelli I'm interested on help on this one. I had similar issues in the past and this is basically a "limitation" on how RN handles non-text components inside of text components.

The solution is basically to add some padding/height around the icon to make sure it is placed properly. There are two ways of doing so:

a) Assume that the line-height/font-size will be basically always the same, in this case is basically hard coded information b) Make a more generic approach that will try to keep the icon at center no matter the font-size.

Of course that B is the optimal solution, but back in the day <Text /> used to require specific dimensions for inline components, so dynamic height may not be achievable.

sidferreira avatar Oct 19 '21 18:10 sidferreira

@arielgreen I would like to help fixing the issue. My approach would be to make the wrapper style to have styel property flex set to "1" with flexDirection to "row", usually we should not add padding to make two things aligned, instead if we use flex container then only thing is to just add alignItems to "center" and its going to work on different screen sizes as well.

itrare avatar Oct 19 '21 23:10 itrare

@AndrewGable please review @itrare 's and @sidferreira 's proposals ^

arielgreen avatar Oct 21 '21 19:10 arielgreen

Sorry I am super slammed with other priorities, going to re-assign for a review.

AndrewGable avatar Oct 25 '21 21:10 AndrewGable

Triggered auto assignment to @iwiznia (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

MelvinBot avatar Oct 25 '21 22:10 MelvinBot

a) Assume that the line-height/font-size will be basically always the same, in this case is basically hard coded information

@sidferreira I don't think this is a safe assumption

b) Make a more generic approach that will try to keep the icon at center no matter the font-size.

@sidferreira Can you expand on this?

My approach would be to make the wrapper style to have styel property flex set to "1" with flexDirection to "row", usually we should not add padding to make two things aligned, instead if we use flex container then only thing is to just add alignItems to "center" and its going to work on different screen sizes as well.

@itrare The wrapper will wrap the whole text? Will that work for multi line text like in this case?

iwiznia avatar Oct 26 '21 11:10 iwiznia

@iwiznia Back in the early days of React Native (~2 years ago lol) the <Text /> component had an explicit mention saying that any non-text embed should have its dimensions (width/height) explicitly set. Although the docs don't mention it anymore, I did some tests and it still seems to be a limitation, that's why I see A as the most solid option.

After reviewing <CopyTextToClipboard /> my proposal is to calculate the lineHeight and fontSize and position the icon accordly, in a way that we can respect different heights (solution B), but not as fluid as we would like.

Using height: 100% and similar is not an option as it would get the <Text /> height, not the lineHeight.

sidferreira avatar Oct 26 '21 17:10 sidferreira

After reviewing my proposal is to calculate the lineHeight and fontSize and position the icon accordly, in a way that we can respect different heights (solution B), but not as fluid as we would like.

Hi @sidferreira. I think your plan here sounds good at a high level, though I'm not sure what you intend to code.

Although the docs don't mention it anymore, I did some tests and it still seems to be a limitation, that's why I see A as the most solid option.

Also, I'm curious to know why the docs don't mention it anymore (to me that would indicate that it's been fixed). What tests did you perform to come to this determination?

Lastly, thanks for your time and interest in the issue!

Luke9389 avatar Oct 26 '21 18:10 Luke9389

@Luke9389 I would have to rely on styles.flexRow, styles.cursorPointer, and this.props.textStyles.

About the docs, I agree, but I did the test and was surprised. The simplest test is something like this:

<View style={{borderWidth: 2, borderColor: 'red'}}>
  <Text>
    AAA {'\n'}
    BBB <View style={{height: '100%', width: 30, backgroundColor: 'blue'}} /> {'\n'}
    CCC
  </Text>
</View>

Styles like alignSelf didn't work as well.

Be sure I'll be glad to be proven wrong as this kind of styling is a pain.

sidferreira avatar Oct 26 '21 19:10 sidferreira

Thanks for the details. I think we're pretty much ready to roll. But first...

So just to be clear, your proposal is to edit the <CopyTextToClipboard /> component by relying on styles.flexRow, styles.cursorPointer, and this.props.textStyles, correct? Just want to be sure I'm understanding the exact game plan. Later when you submit a PR and we are testing it, it's nice to have a very clearly spelled out proposal.

In general, we tend to look for proposals that aren't rephrasing the solution in the issue description. So this for example was close, but still not specific enough for me:

my proposal is to calculate the lineHeight and fontSize and position the icon accordingly, in a way that we can respect different heights

I'm saying this to be helpful and friendly, I think you're doing great so far. 👍

Luke9389 avatar Oct 27 '21 18:10 Luke9389

@Luke9389 To be a bit more explicit:

The component <CopyTextToClipboard /> is related to 3 styles:

  • styles.flexRow
  • styles.cursorPointer
  • this.props.textStyles (not in use as far as I checked in the 3 places that <CopyTextToClipboard /> is used.

My proposal is to have a function to extract lineHeight and/or fontSize of the styles and then calculate a value to be used as height of a view inside which the icon will be placed. This view will then center the icon properly using padding + the icon height.

sidferreira avatar Oct 27 '21 19:10 sidferreira

And the reason we're using padding is because flexbox doesn't work on an image component inside of a text component, correct?

Luke9389 avatar Oct 27 '21 19:10 Luke9389

@Luke9389 We can use flexbox but I won't be surprised if it doesn't align with the text 100%

sidferreira avatar Oct 27 '21 19:10 sidferreira

Well, we can try both on the PR. You've got the 🟢 green light 🟢 to go ahead and get started.

Luke9389 avatar Oct 27 '21 19:10 Luke9389

Waiting for assignment / upwork @Luke9389

sidferreira avatar Oct 28 '21 02:10 sidferreira

@sidferreira As you are a new contributor, you can only work on one task at a time. Please refer to contribution guidelines. Looks like we have reached to a consent on the proposal so we may hold before assigning this issue to you.

parasharrajat avatar Oct 28 '21 20:10 parasharrajat