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

Feature: Render markdown in thread header #24574

Closed

Conversation

tienifr
Copy link
Contributor

@tienifr tienifr commented Aug 15, 2023

Details

Expected outcome for thread name in LHN:

  • Only the first line of the message should display on the thread title with no trailing space

Expected outcome for thread header:

  • Only the first line of the message should display on the thread title with no trailing space
  • Markdown, if in a thread title, should display as markdown
    • Heading markdown should display as text only (no formatting)
    • Code fence should display as inline code

Fixed Issues

$ #22832
PROPOSAL: #22832 (comment)

Tests

  1. Login with any account
  2. Go to any report
  3. Send a message with multiline code fence (3 backticks markdown)
  4. Reply in thread
  5. Verify that thread header displays as the expected outcome
    ====
  6. Repeat step 2-5 with all supported markdowns: # Heading, Inline code, Link, Email, Bold, Italic, Strikethrough, > Quote, Mention user, Mention here.
  7. Back to LHN, verify that thread's report name displays as expected outcome
  • Verify that no errors appear in the JS console

Offline tests

NA

QA Steps

Expected outcome for thread header:

  • Only the first line of the message should display on the thread title with no trailing space
  • Markdown, if in a thread title, should display as markdown
    • Heading markdown should display as text only (no formatting)
    • Code fence should display as inline code
  1. Login with any account
  2. Go to any report
  3. Send a message with multiline code fence (3 backticks markdown)
  4. Reply in thread
  5. Verify that thread header displays as the expected outcome
    ====
  6. Repeat step 2-5 with all supported markdowns: # Heading, Inline code, Link, Email, Bold, Italic, Strikethrough, > Quote, Mention user, Mention here.
  7. Back to LHN, verify that thread's report name displays as expected outcome
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
      • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web image image image image image image image image image image image
Mobile Web - Chrome

image

image

image

image

image

image

image

image

image

image

image

Mobile Web - Safari

simulator_screenshot_F77EC10F-4E88-409D-B463-54E68068443B
Simulator Screenshot - iPhone 15 Pro Max - 2023-10-13 at 16 38 45
Simulator Screenshot - iPhone 15 Pro Max - 2023-10-13 at 16 38 48
Simulator Screenshot - iPhone 15 Pro Max - 2023-10-13 at 16 38 55
Simulator Screenshot - iPhone 15 Pro Max - 2023-10-13 at 16 38 59
Simulator Screenshot - iPhone 15 Pro Max - 2023-10-13 at 16 39 02
Simulator Screenshot - iPhone 15 Pro Max - 2023-10-13 at 16 39 05
Simulator Screenshot - iPhone 15 Pro Max - 2023-10-13 at 16 39 08
Simulator Screenshot - iPhone 15 Pro Max - 2023-10-13 at 16 39 12
Simulator Screenshot - iPhone 15 Pro Max - 2023-10-13 at 16 39 20
Simulator Screenshot - iPhone 15 Pro Max - 2023-10-13 at 16 39 23
Simulator Screenshot - iPhone 15 Pro Max - 2023-10-13 at 16 39 26

Desktop
iOS

simulator_screenshot_2EE60272-34FA-4BD7-93F4-0F2F4D6AD35F
simulator_screenshot_1A3F69EF-B8BE-471E-A145-DB020AC22074
simulator_screenshot_1C204730-8EB9-4ACE-986E-55F23C8C9DEC
simulator_screenshot_164799CE-6E7D-4A74-A839-7641FFA40801
simulator_screenshot_F690579A-2491-4164-81A0-2469A9B38706
simulator_screenshot_20C353EA-AD08-4D88-BDD8-648167C98086
simulator_screenshot_CE2CEB81-9D43-4BA2-9415-8601CFBF245A
simulator_screenshot_1B40B9CE-F8E4-4C4C-971A-71445C815B17
simulator_screenshot_C68C2C2F-08D7-43BC-B837-711F29781F47
simulator_screenshot_709D6775-CB18-4D8B-899A-C0BE35FFC261
simulator_screenshot_2A776E94-2851-4BCE-89D9-AECE5647280F
simulator_screenshot_DE5371FA-5C92-4599-BEFC-DB62EF716E48

Android

Screenshot_1697185621
Screenshot_1697188475
Screenshot_1697188485
Screenshot_1697188532
Screenshot_1697188537
Screenshot_1697188541
Screenshot_1697188545
Screenshot_1697188550
Screenshot_1697188575
Screenshot_1697188580
Screenshot_1697188584
Screenshot_1697188589

@tienifr tienifr force-pushed the feature/render-markdown-in-thread-header branch from bacceb3 to eea1007 Compare August 18, 2023 09:28
@tienifr tienifr marked this pull request as ready for review August 18, 2023 11:10
@tienifr tienifr requested a review from a team as a code owner August 18, 2023 11:10
@melvin-bot melvin-bot bot requested review from sobitneupane and removed request for a team August 18, 2023 11:10
@melvin-bot
Copy link

melvin-bot bot commented Aug 18, 2023

@sobitneupane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@tienifr
Copy link
Contributor Author

tienifr commented Aug 18, 2023

I got a problem when using RenderHTML inside Text. So far I've found no way to pass numberOfLines to RenderHTML which makes the text un-truncated but hidden instead:

image

@sobitneupane
Copy link
Contributor

@tienifr Any update?

@tienifr
Copy link
Contributor Author

tienifr commented Aug 22, 2023

@sobitneupane Worked on Web:

image

image

Basically, I'll introduce a new custom tag thread-title and pass numberOfLines like this:

'thread-title': defaultHTMLElementModels.span.extend({
    reactNativeProps: {
        text: {numberOfLines: 1},
    },
}),

@tienifr
Copy link
Contributor Author

tienifr commented Aug 22, 2023

Worked on native as well:

image

Copy link
Contributor

@sobitneupane sobitneupane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am yet to review all the cases. But initial tests are quite promising. Thanks for the work @tienifr

The header still overflows.

Screen.Recording.2023-08-23.at.16.03.21.mov
Screenshot 2023-08-23 at 16 30 02

Copy link
Contributor

@sobitneupane sobitneupane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tienifr Since we are only using first line in the header, should we do the same in LHN as well? What do you think?

@sobitneupane
Copy link
Contributor

sobitneupane commented Aug 23, 2023

Arrow on TaskPreview is overlapping with text.

@tienifr
Copy link
Contributor Author

tienifr commented Mar 12, 2024

Update:

  1. For quoted text, the hoisting process of react-native-render-html would automatically translate thread-title wrapper in a View when its children contained a View (blockquote is a View). That deactivated numberOfLines prop.
  2. On native, we render the code block by truncating a series of Views, each corresponds to a word. Wrapping Views inside Text (thread-title wrapper) caused unexpected results.
  3. Maybe same as ^.

I'll resolve those ASAP.

@tienifr
Copy link
Contributor Author

tienifr commented Mar 14, 2024

Update: Found a solution. I'm curating the code changes. Will push the tonight.

@sobitneupane
Copy link
Contributor

@tienifr Any update?

@tienifr
Copy link
Contributor Author

tienifr commented Apr 1, 2024

Update: My new solution worked very well on native but failed on web. I think that's because I'm wrapping the thread title inside a View. Seperating platform-specific files might be the last resort.

@tienifr
Copy link
Contributor Author

tienifr commented Apr 5, 2024

I'm still working on the fix for Web. Resolving one platform would cause failure for the others.

@sobitneupane
Copy link
Contributor

@tienifr Let's focus on this issue. Can you please update where you are stuck now?

@sobitneupane
Copy link
Contributor

sobitneupane commented Apr 22, 2024

What can we do to get this PR merged asap? We can open follow up PR for some implementations if it doesn't break anything.

@sobitneupane
Copy link
Contributor

Any update @tienifr ?

@tienifr
Copy link
Contributor Author

tienifr commented May 20, 2024

I'm still blocking on these issues #24574 (comment) where blockquote does not work properly. I found the root cause but no optimal solution had been found. If we want merging ASAP, I think we should exclude blockquote from thread-title and resolve in future PRs.

@sobitneupane
Copy link
Contributor

sobitneupane commented May 21, 2024

I'm still blocking on these issues #24574 (comment) where blockquote does not work properly. I found the root cause but no optimal solution had been found. If we want merging ASAP, I think we should exclude blockquote from thread-title and resolve in future PRs.

@tienifr Yup. That sounds like a good idea. Please test it thoroughly at your end, update the screen recordings and let me know. Let's wrap this up before weekend.

@tienifr tienifr requested a review from a team as a code owner May 24, 2024 09:38
@tienifr
Copy link
Contributor Author

tienifr commented May 24, 2024

I'm testing again since there have been many changes to the report title logics.

@shawnborton
Copy link
Contributor

Let us know when there are updated screenshots to review, thanks!

@shawnborton
Copy link
Contributor

Actually... I'm kind of curious why we are even doing this in the first place. Going to head to the original issue to discuss.

@tienifr
Copy link
Contributor Author

tienifr commented May 24, 2024

@shawnborton Working screenshots are in PR description.

@shawnborton
Copy link
Contributor

Can you update them with the latest? They seem quite dated:
CleanShot 2024-05-24 at 16 15 57@2x

Either way, we are discussing in Slack and I think it might have been a mistake to allow for the markdown to appear in the report headers, especially with no clean way of truncating things.

So let's pause for a moment until we get clarification from @JmillsExpensify, but I think we should keep the report headers as just our normal app text style.

@shawnborton
Copy link
Contributor

What's the latest here? Can we just close this one?

@shawnborton
Copy link
Contributor

Friendly bump @tienifr and @sobitneupane - what's the status with this one?

@sobitneupane
Copy link
Contributor

sobitneupane commented Jul 16, 2024

@shawnborton Looks like we don't want to make the change introduced by this PR. So, I think we are good to close this out.

I have asked for update in the issue.

@shawnborton
Copy link
Contributor

Sounds good, closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants