-
Notifications
You must be signed in to change notification settings - Fork 4k
Render report field name as HTML only when needed #95661
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
base: main
Are you sure you want to change the base?
Changes from all commits
ebfe9d5
8a501ab
0f840ab
37e5fd5
5394e44
32fc032
aa15fb5
57b822a
98704c0
39e136b
f896edb
a8229ce
80e5f14
f90083a
f62c78c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -298,7 +298,7 @@ type MenuItemBaseProps = ForwardedFSClassProps & | |
| /** The type of brick road indicator to show. */ | ||
| brickRoadIndicator?: ValueOf<typeof CONST.BRICK_ROAD_INDICATOR_STATUS>; | ||
|
|
||
| /** Should render the content in HTML format */ | ||
| /** Should render the content in HTML format. A title without HTML content is rendered as plain text even when this is set. */ | ||
| shouldRenderAsHTML?: boolean; | ||
|
|
||
| /** Whether or not the text should be escaped */ | ||
|
|
@@ -752,6 +752,8 @@ function MenuItem({ | |
| return Parser.replace(helperText, {shouldEscapeText}); | ||
| }, [helperText, shouldParseHelperText, shouldEscapeText]); | ||
|
|
||
| const shouldRenderTitleAsHTML = shouldRenderAsHTML && !!title && Parser.isHTML(title); | ||
|
|
||
| const processedTitle = useMemo(() => { | ||
| let titleToWrap = ''; | ||
| if (shouldRenderAsHTML) { | ||
|
|
@@ -1050,7 +1052,14 @@ function MenuItem({ | |
| > | ||
| {!!title && (shouldRenderAsHTML || (shouldParseTitle && !!html.length)) && ( | ||
| <View style={[styles.renderHTMLTitle, styles.textAlignLeft, shouldApplyIconPaddingToHTMLTitle && iconLeftPadding]}> | ||
| <RenderHTML html={processedTitle} /> | ||
| {/* Use Text instead of RenderHTML when the title is plain text. | ||
| Titles with shouldRenderAsHTML use baseFontStyle, which differs from combinedTitleTextStyle below. | ||
| */} | ||
| {shouldRenderTitleAsHTML || shouldParseTitle ? ( | ||
| <RenderHTML html={processedTitle} /> | ||
| ) : ( | ||
| <Text style={styles.webViewStyles.baseFontStyle}>{convertToLTR(Parser.htmlToText(processedTitle))}</Text> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary When
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The wrap-then-strip pattern looks redundant. However, it exists because the processedTitle logic always appends , regardless of whether the output is HTML or plain text. If we remove Parser.htmlToText, the user will see literal "" tags in the text. The truncation logic in processedTitle is awkward, but refactoring it is out of scope for this PR, so we retain the existing pipeline. |
||
| )} | ||
|
jmgraa marked this conversation as resolved.
|
||
| </View> | ||
| )} | ||
| {!shouldRenderAsHTML && !shouldParseTitle && !!title && ( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.