Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD for payment 2023-10-23] [HOLD for payment 2023-10-23] [HOLD for payment 2023-10-20] [HOLD for payment 2023-10-20] [$500] Desktop - Monospace font for code block doesn't work on desktop #27626

Closed
1 of 6 tasks
kbecciv opened this issue Sep 17, 2023 · 53 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Sep 17, 2023

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. Log in with any account
  2. Use monospace font for code blocks

Example:
Screenshot 2023-08-31 at 3 52 09 PM (1)

Expected Result:

Monospace font for code blocks should work on desktop

Actual Result:

Monospace font for code blocks doesn't work on desktop

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.70.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

n/a

Expensify/Expensify Issue URL:
Issue reported by: @rafecolton
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693522327341959

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01da4c270f6ad4ac3e
  • Upwork Job ID: 1704446525579890688
  • Last Price Increase: 2023-09-27
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 17, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 17, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 17, 2023

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

@kbecciv kbecciv changed the title Desktop - Monospace font for code blocks doesn't work on desktop Desktop - Monospace font for code block doesn't work on desktop Sep 17, 2023
@rafecolton
Copy link
Member

This is a regression so let's ensure it gets added to the regression checklist before it's closed 🙏

@akinwale
Copy link
Contributor

akinwale commented Sep 18, 2023

Proposal

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

The monospace font is not being used for code blocks on desktop and web.

What is the root cause of that problem?

On web and desktop, the PreRenderer outputs <pre>...</pre> as <comment><pre>...</pre></comment>. The default text style used here is styles.webViewStyles.baseFontStyle which is defined as the baseStyle for the root TRenderEngineProvider in the BaseHTMLEngineProvider component because the Expensify monospace font was not recognised based on how the font family entries were defined.

<TRenderEngineProvider
customHTMLElementModels={customHTMLElementModels}
baseStyle={styles.webViewStyles.baseFontStyle}

Since the system fonts specified for the HTML engine provider are comma-separated, and it's impossible to apply multiple fonts at the same time, the individual Expensify fonts are not recognised when using the custom HTML renderers. Note that this is not the case on iOS / Android native as custom fonts are handled differently.

This is a regression from #19874.

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

Solution 1
Similar to how there's a fallback font for ExpensifyNeue-Regular in BaseHTMLEngineProvider, add another entry for the monospace font so that the custom renderer can recognise it as a font that can be applied.

-const fallbackFonts = {'ExpensifyNeue-Regular': fontFamily.EXP_NEUE};
+const fallbackFonts = {'ExpensifyNeue-Regular': fontFamily.EXP_NEUE, 'ExpensifyMono-Regular': fontFamily.MONOSPACE};

This is preferred to Solution 2, since it uses the same approach taken in #19874 for the base Expensify Neue font, and it is least likely to cause another regression with the emojis.

Solution 2
Add a non-comma separated entry for ExpensifyMono-Regular to src/styles/fontFamily/index.ts. fontFamily/types.ts also has to be updated with the key, MONOSPACE_REGULAR or whatever key name we decide to adopt.

+MONOSPACE_REGULAR: 'ExpensifyMono-Regular',

What alternative solutions did you explore? (Optional)

In BasePreRenderer, we can iterate over each text line and line break from the pre source using defaultRendererProps.tnode.children and then render using Text components, manually applying the corresponding font family and other applicable styles.

Screenshot 2023-09-18 at 02 01 43

@akinwale
Copy link
Contributor

akinwale commented Sep 18, 2023

This is a regression so let's ensure it gets added to the regression checklist before it's closed 🙏

It doesn't look like this is a regression (or at least not a recent one). I thought I was going crazy, but I tested with a bunch of earlier releases, and it looks like I've never actually seen the monospace font for code blocks on web and desktop. The monospace font did work fine on iOS / Android native, however.

I've figured out a fix.

@rafecolton
Copy link
Member

rafecolton commented Sep 18, 2023

How far back did you test? It worked when we first introduced the feature. So it is 100% a regression, recent or not

@akinwale
Copy link
Contributor

How far back did you test? It worked when we first introduced the feature. So it is 100% a regression, recent or not

Up to 1.3.50-0. I was prepared to go further back. 😅

My first PR related to the feature was about 4 weeks ago, which is where I noticed from the desktop and web screenshots that the code block wasn't actually rendered using a monospace font.

@akinwale
Copy link
Contributor

@rafecolton I think this is where the regression was introduced: #19874

@bernhardoj
Copy link
Contributor

Proposal

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

Monospace font for code block doesn't work on web/desktop.

What is the root cause of that problem?

As correctly pointed out by @akinwale, this is a regression from #19874 where we set a list of font family alternatives to each font family, for the web platform. In BaseHTMLEngineProvider, we have a comment saying that multiple font families don't work, so we have a fallback font which is being used in code block.

// We need to pass multiple system-specific fonts for emojis but
// we can't apply multiple fonts at once so we need to pass fallback fonts.
const fallbackFonts = {'ExpensifyNeue-Regular': fontFamily.EXP_NEUE};

It's not because react-native-render-html can't handle it, but it is because we are doing it wrong.

react-native-render-html documentation explain it pretty well, that yes RN (native) only able to handle one font-family but react-native-render-html will pick the one (from the comma-seperated list) that is available in systemFonts list.

CSS ​font-family and ​font properties allow a comma-separated list of fonts, but React Native styles fontFamily allows only one font name. With the ​TRE, you can instruct which fonts are available in the system (or fonts you have added), and it will pick the first match! The prop to achieve that is ​systemFonts.

In our current code, we already pass the font family list to systemFonts

systemFonts={_.values(fontFamily)}

but the list is the one that contains multiple font family alternatives. So, the systemFonts value is:
['ExpensifyNeue-Italic, Segoe UI Emoji, Noto Color Emoji', 'ExpensifyNeue-Regular, Segoe UI Emoji, Noto Color Emoji', 'ExpensifyNewKansas-Medium, Segoe UI Emoji, Noto Color Emoji', and so on...]

which makes react-native-render-html unable to recognize any custom fonts we have.

why code fence font family is monospace then? That is because we are manually set the font family in CodeRenderer

this issue is not limited to monospace font but also to other font family

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

We need to pass the individual list of each of our custom font family. The simplest way is to import the fontFamily/index.native.js file and use it as systemFonts.

import singleFontFamily from '../../styles/fontFamily/index.native';

systemFonts={_.values(singleFontFamily)}

or

We can create new font family file called singleFontFamily.js and multipleFontFamily.js. fontFamily/index.native.js will export singleFontFamily while fontFamily/index.js will export multipleFontFamily. In BaseHTMLEngineProvider, we will just import singleFontFamily to use in systemFonts.


This way, we don't need the fallbackFonts anymore.

@melvin-bot melvin-bot bot added the Overdue label Sep 20, 2023
@bfitzexpensify bfitzexpensify added the External Added to denote the issue can be worked on by a contributor label Sep 20, 2023
@melvin-bot melvin-bot bot changed the title Desktop - Monospace font for code block doesn't work on desktop [$500] Desktop - Monospace font for code block doesn't work on desktop Sep 20, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 20, 2023

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 20, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 20, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 20, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 21, 2023

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

@bfitzexpensify
Copy link
Contributor

Couple of proposals ready for you to review @mananjadhav

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Sep 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

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

@mananjadhav
Copy link
Collaborator

Reviewing this.

@melvin-bot melvin-bot bot removed the Overdue label Sep 25, 2023
@mananjadhav
Copy link
Collaborator

Because I wanted to implement and test the proposals, I attempted to reproduce the error. Am I missing something? I can't seem to reproduce this?

image

@bernhardoj
Copy link
Contributor

@mananjadhav that's really weird. Even your LHN subtitle text has a monospace font. Maybe there are some changes you made in the code?

@melvin-bot melvin-bot bot added the Weekly KSv2 label Oct 16, 2023
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2023-10-20] [HOLD for payment 2023-10-20] [$500] Desktop - Monospace font for code block doesn't work on desktop [HOLD for payment 2023-10-23] [HOLD for payment 2023-10-20] [HOLD for payment 2023-10-20] [$500] Desktop - Monospace font for code block doesn't work on desktop Oct 16, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.84-10 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-23. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@mananjadhav] The PR that introduced the bug has been identified. Link to the PR:
  • [@mananjadhav] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@mananjadhav] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@mananjadhav] Determine if we should create a regression test for this bug.
  • [@mananjadhav] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@puneetlath / @bfitzexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Oct 16, 2023
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2023-10-23] [HOLD for payment 2023-10-20] [HOLD for payment 2023-10-20] [$500] Desktop - Monospace font for code block doesn't work on desktop [HOLD for payment 2023-10-23] [HOLD for payment 2023-10-23] [HOLD for payment 2023-10-20] [HOLD for payment 2023-10-20] [$500] Desktop - Monospace font for code block doesn't work on desktop Oct 16, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.84-10 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-23. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@mananjadhav] The PR that introduced the bug has been identified. Link to the PR:
  • [@mananjadhav] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@mananjadhav] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@mananjadhav] Determine if we should create a regression test for this bug.
  • [@mananjadhav] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@bfitzexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@bfitzexpensify bfitzexpensify added Daily KSv2 and removed Weekly KSv2 labels Oct 19, 2023
@melvin-bot melvin-bot bot added the Overdue label Oct 19, 2023
@bfitzexpensify
Copy link
Contributor

Switching this to daily so that I'm on top of it and pay it out when it's due

@melvin-bot melvin-bot bot added Daily KSv2 and removed Overdue Daily KSv2 labels Oct 19, 2023
@bfitzexpensify
Copy link
Contributor

Due 10/23

@melvin-bot melvin-bot bot added the Overdue label Oct 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 24, 2023

@puneetlath, @mananjadhav, @bfitzexpensify, @bernhardoj Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@mananjadhav
Copy link
Collaborator

@bfitzexpensify This is ready for payout, can you please post the payment summary?

@melvin-bot melvin-bot bot removed the Overdue label Oct 24, 2023
@bfitzexpensify
Copy link
Contributor

Payment summary:

Contributor: @bernhardoj - $750 for completion and urgency bonus (the automation didn't pick it up but I'm seeing assignment on 10/9 and merging on 10/10) to be paid via Upwork
C+: @mananjadhav $750 for completion and urgency bonus to be paid via manual request

@JmillsExpensify
Copy link

$750 payment approved for @mananjadhav based on comment above.

@melvin-bot melvin-bot bot added the Overdue label Oct 26, 2023
@bfitzexpensify
Copy link
Contributor

A reminder to complete the BZ checklist when you get a moment @mananjadhav - thanks!

@melvin-bot melvin-bot bot removed the Overdue label Oct 27, 2023
@mananjadhav
Copy link
Collaborator

@bfitzexpensify I couldn't pinpoint to a specific PR that could've caused this. But I think it makes sense to add a regression for this one.

Regression Test Proposal

  1. Open any chat
  2. Send a code block text to any chat, e.g.
    code block
  3. Verify the font is a monospace font.
  4. Enter a single line code block code block.
  5. Verify the font is a monospace font.

@bfitzexpensify
Copy link
Contributor

Cool, I like that test. Opened https://github.com/Expensify/Expensify/issues/330780 to get it added. We're all done here, thanks everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

8 participants