Skip to content

[HOLD for payment 2024-01-09] [$500] Chat - Single line code blocks are not vertically centered #31427

Closed

Description

@izarutskaya

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


Version Number: 1.4.0-0
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
Expensify/Expensify Issue URL:
Issue reported by: Applause-Internal Team
Slack conversation: @

Action Performed:

Pre-requisite: user must be logged in.

  1. Go to any chat.
  2. Send a single line code block (like test)

Expected Result:

The text inside the block should be centered.

Actual Result:

The text is horizontally centered, but not vertically, is closer to the bottom.

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6278669_1700114885241!IMG_E1595

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0173268787598947ed
  • Upwork Job ID: 1725103891916292096
  • Last Price Increase: 2023-12-01
  • Automatic offers:
    • tienifr | Contributor | 28013519

Activity

  1. added
    External
    Daily
    Bug
    on Nov 16, 2023
  2. changed the title [-]Chat - Single line code blocks are not vertically centered[/-] [+][$500] Chat - Single line code blocks are not vertically centered[/+] on Nov 16, 2023
  3. melvin-bot commented on Nov 16, 2023

    @melvin-bot
  4. melvin-bot commented on Nov 16, 2023

    @melvin-bot

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

  5. added
    Help Wanted
    on Nov 16, 2023
  6. melvin-bot commented on Nov 16, 2023

    @melvin-bot

    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
  7. melvin-bot commented on Nov 16, 2023

    @melvin-bot

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

  8. ZhenjaHorbach commented on Nov 16, 2023

    @ZhenjaHorbach
    Contributor

    Proposal

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

    Chat - Single line code blocks are not vertically centered

    What is the root cause of that problem?

    The main problem is that we are using the wrong line height Which does not match the font size
    As a result, the text moves down.

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

    const codeTextStyle: CodeTextStyles = {
    lineHeight: 18,
    };

    Especially for iOS we have a separate file where we set the line height

    We can reduce this value so that it matches font size

    And change this value so that it matches the font size

    Some updates:

    We can use the result of this function or make a similar function for lineHeight with the same result

    function getCodeFontSize(isInsideH1: boolean) {
    return isInsideH1 ? 15 : 13;
    }

    And pass in this style object

    const textStyleOverride = {
    fontSize,
    fontFamily: font,
    // We need to override this properties bellow that was defined in `textStyle`
    // Because by default the `react-native-render-html` add a style in the elements,
    // for example the <strong> tag has a fontWeight: "bold" and in the android it break the font
    fontWeight: undefined,
    fontStyle: undefined,
    };

    (And delete from this place(Or at least make these changes specific only to iOS, but I think it will work well on all platforms))

    ...(codeStyles.codeTextStyle as MixedStyleDeclaration),

    As a result

    Screenshot 2023-11-16 at 12 13 32

    What alternative solutions did you explore? (Optional)

    NA

  9. tienifr commented on Nov 16, 2023

    @tienifr
    Contributor

    Proposal

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

    The text is horizontally centered, but not vertically, is closer to the bottom.

    What is the root cause of that problem?

    In here, we set the lineHeight to 18, different from fontSize (which is 13 or 15) because we want to render any emoji inside text fully and vertically centered. But this causes problem for text without emoji, it will not be vertically centered. We can see from the image above a text with emoji and text without emoji
    Screenshot 2023-11-16 at 20 00 38
    (They are on the same line yet are different chunks, due to the text matrix implementation here)

    The text with emoji is rendered following the height of the emoji, so it will be vertically centered, so as the emoji. The text without emoji will follow the height of the text, which is equal to the font size and the text will appear lower.

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

    In textMatrix, we need to split out the emoji from the text, for emoji chunk, we'll follow current logic, for text-without-emoji chunk, the lineHeight will be set equal to the fontSize, and the text will be vertically centered as usual.

    What alternative solutions did you explore? (Optional)

    Increase the code word wrapper height in iOS to 22 will also center both the text and emoji. We can do similarly for Android if there's issue there.

    Different root cause, but emoji in code in h1 is currently cut, that can be potentially fixed by increasing the lineHeight of text when h1, similar to what we did for font size.

  10. Krishna2323 commented on Nov 16, 2023

    @Krishna2323
    Contributor

    Proposal

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

    Chat - Single line code blocks are not vertically centered

    What is the root cause of that problem?

    We have increased lineHeight for codeTextStyle in IOS devices but we forgot to increase the height for the codeWordStyle.

    const codeTextStyle: CodeTextStyles = {
    lineHeight: 18,
    };

    const codeWordStyle: CodeWordStyles = {
    height: 18,
    top: 4,
    };

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

    We need to increase the height of the codeWordStyle. Increasing it to 20 works well, looks similar to android.

    Result

    IOS after fix:
    Monosnap iPhone 14 Pro Max 2023-11-16 18-53-02

    Android without any changes:
    WhatsApp Image 2023-11-16 at 18 56 02

  11. shubham1206agra commented on Nov 16, 2023

    @shubham1206agra
    Contributor

    This is dupe of #8132

  12. 91 remaining items

  13. melvin-bot commented on Jan 15, 2024

    @melvin-bot

    @robertjchen, @trjExpensify, @NicMendonca, @thesahindia, @tienifr Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  14. added
    Reviewing
    on Jan 15, 2024
  15. robertjchen commented on Jan 15, 2024

    @robertjchen
    Contributor

    Awaiting completion of BZ checklist

  16. thesahindia commented on Jan 16, 2024

    @thesahindia
    Member

    I couldn't find the responsible PR that caused this.

    We can add a test case if we want. Here are the steps -

    1. Open any chat
    2. Send a message mixed with emoji and alphabets in single line code block (i.e. 😁 Hi)
    3. Verify that emoji and alphabets are vertically centered.
  17. NicMendonca commented on Jan 17, 2024

    @NicMendonca
    Contributor

    fab ! thanks!

  18. JmillsExpensify commented on Jan 22, 2024

    @JmillsExpensify
    Contributor

    @NicMendonca Can you add specific payment amounts to this summary?

  19. NicMendonca commented on Jan 22, 2024

    @NicMendonca
    Contributor

    BZ Payment summary:

    • Contributor: @tienifr - $500 paid through Upwork
    • Contributor +: @thesahindia - $500 paid through Expensify
  20. JmillsExpensify commented on Jan 22, 2024

    @JmillsExpensify
    Contributor

    $500 approved for @thesahindia based on the comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyEngineeringExternalReviewing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions