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

Allow HTML for task titles #55967

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open

Allow HTML for task titles #55967

wants to merge 40 commits into from

Conversation

johnmlee101
Copy link
Contributor

@johnmlee101 johnmlee101 commented Jan 29, 2025

Explanation of Change

This opens up being able to set and display html titles in plain text for most flows within the product. Pt. 2 of this by @Krishna2323 will add html rendering to the appropriate spots.

Fixed Issues

$ #53175
PROPOSAL: #53175 (comment)

Tests

  1. Create a task with title: Title and see that it shows as Title in the quick view, but in the actual title, it is dispalyed with markdown rendering (bold).
  2. Check that the previews for editing and creating titles are shown in markdown and you should never see <b>Title</b> or <em>Title</em>.
  3. In the report action preview it should just be Title, no markdown.
  • Verify that no errors appear in the JS console

Offline tests

image image

QA Steps

  1. Create a task with title: Title and see that it shows as Title in the quick view, but in the actual title, it is dispalyed with markdown rendering (bold).
  2. Check that the previews for editing and creating titles are shown in markdown and you should never see <b>Title</b> or <em>Title</em>.
  3. In the report action preview it should just be Title, no markdown.
  • 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: mWeb Chrome
    • iOS: Native
    • iOS: mWeb 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 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 used JaimeGPT to get English > Spanish translation. I then posted it 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • 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.ts 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 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(theme.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 the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • 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.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • 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 verified that similar component doesn't exist in the codebase
  • I verified that all props are defined accurately and each prop has a /** comment above it */
  • I verified that each file is named correctly
  • I verified that each component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
  • I verified that the only data being stored in component state is data necessary for rendering and nothing else
  • In component if we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
  • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
  • I verified that component 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)
  • I verified that all JSX used for rendering exists in the render method
  • I verified that each 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

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2025-01-29.at.3.06.44.PM.mov
Screen.Recording.2025-01-30.at.2.51.08.PM.mov
MacOS: Desktop

@johnmlee101 johnmlee101 self-assigned this Jan 29, 2025
@johnmlee101 johnmlee101 marked this pull request as ready for review January 29, 2025 20:18
@johnmlee101 johnmlee101 requested a review from a team as a code owner January 29, 2025 20:18
@johnmlee101 johnmlee101 changed the title Allow HTML for task titles [HOLD web] Allow HTML for task titles Jan 29, 2025
@johnmlee101 johnmlee101 changed the title [HOLD web] Allow HTML for task titles [HOLD BE] Allow HTML for task titles Jan 29, 2025
@johnmlee101
Copy link
Contributor Author

johnmlee101 commented Jan 29, 2025

@melvin-bot melvin-bot bot requested review from amyevans and removed request for a team January 29, 2025 20:18
Copy link

melvin-bot bot commented Jan 29, 2025

@amyevans 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]

@johnmlee101
Copy link
Contributor Author

tests are because of a known broken test

@johnmlee101
Copy link
Contributor Author

updated, please re-review

@johnmlee101
Copy link
Contributor Author

nvm the default needs to change again, since its a string default we can't provide a value here

@johnmlee101
Copy link
Contributor Author

ready for review!

@johnmlee101 johnmlee101 changed the title [HOLD BE] Allow HTML for task titles Allow HTML for task titles Feb 5, 2025
@mananjadhav
Copy link
Collaborator

Reviewing the updated changes. Will have this finished by tomorrow.

@johnmlee101
Copy link
Contributor Author

Let me know if you plan on getting to this today!

@mananjadhav
Copy link
Collaborator

Yes I'll get to this in an hour.

@mananjadhav
Copy link
Collaborator

Starting with this now.

@mananjadhav
Copy link
Collaborator

mananjadhav commented Feb 6, 2025

@johnmlee101 I found a couple of issues issue while testing. If I use a keyboard shortcut on description, the title ends up showing the HTML.

  1. Create a task with Title say in italic, save the task.
  2. Add a description, use a keyboard shortcut to make it bold/italic.
  3. Save the description, you'll end up seeing the title with tags <em>Title</em>.
  4. You keep editing the description, you'll end up having encoded title.
  5. Add the title with heading # Title will cause an alignment issue with the checkbox.
web-task-title.mov
web-task-title-encoded.mov
web-task-title-alignment

@johnmlee101
Copy link
Contributor Author

very odd, I'll take a look

@mananjadhav
Copy link
Collaborator

Quick question, even if I've not added # and now that we have markdown will the title still be a larger font size? If you compare the title and link you'll see different font sizes.

image

@shawnborton
Copy link
Contributor

Hmm that's probably technically correct, but why doesn't the link use the larger headline style as well in your example?

cc @Expensify/design

@mananjadhav
Copy link
Collaborator

but why doesn't the link use the larger headline style as well in your example

I think it will need fixing. cc - @johnmlee101

@mananjadhav
Copy link
Collaborator

Another question, with markdown now, do we support multiline title? Looks like in the current PR update task title supports multiline but create task doesn't.

@johnmlee101
Copy link
Contributor Author

fixed!

@johnmlee101
Copy link
Contributor Author

but why doesn't the link use the larger headline style as well in your example?

This gets into the styling overlap between markdown and task titles I'd imagine, not 100% sure what the problem is however and how to fix it

@shawnborton
Copy link
Contributor

Basically I would expect the entire title to look like our headline style, and the the linked portion is just blue but retains the same font size/boldness of the headline. Let me know if that makes sense, otherwise I am happy to mock something up.

But basically just imaging having something like this: <h1>Here is my <a href="#">linked</a> title</h1>

@johnmlee101
Copy link
Contributor Author

But basically just imaging having something like this: <h1>Here is my <a href="#">linked</a> title</h1>

unfortunately # title here is actually a downsize to the current task titles. So I'm curious what we need to change to the task titles

@johnmlee101
Copy link
Contributor Author

e.g.
image

@shawnborton
Copy link
Contributor

Hmm I don't think we're on the same page here. The idea is that the link portion here should match the part that says "Test"
CleanShot 2025-02-06 at 11 26 50@2x

That being said... I am realizing that our task titles already use a headline-esque style, so I am wondering why we even need to worry about changing that here? But yes, we want the link portion to match the rest of the text.

@johnmlee101
Copy link
Contributor Author

But yes, we want the link portion to match the rest of the text.

Yeah this is the part I might need some redirection on where to modify this

@johnmlee101
Copy link
Contributor Author

asking in opensource

Copy link
Contributor

@c3024 c3024 left a comment

Choose a reason for hiding this comment

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

Only Text nodes that are direct children of Text nodes can inherit styles from parent nodes.

When the TNodeChildRenderer inside TaskTitleRenderer recursively renders AnchorRenderer, it seems that the direct Text child relationship is broken.

We can pass the style to the Text node here in AnchorRenderer to fix this.

-                style={styles.link}
+                style={[style, styles.link]}

@@ -111,7 +111,7 @@ function TaskView({report}: TaskViewProps) {
numberOfLines={3}
style={styles.taskTitleMenuItem}
>
{taskTitle}
<RenderHTML html={`<task-title>${taskTitle}</task-title>`} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Haven't found anything broken with this but react-native-render-html warns against using RenderHTML as a child inside Text node.

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.

5 participants