Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/components/DisplayNames/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ import TextWithEmojiFragment from '@pages/home/report/comment/TextWithEmojiFragm
import type DisplayNamesProps from './types';

// As we don't have to show tooltips of the Native platform so we simply render the full display names list.
function DisplayNames({accessibilityLabel, fullTitle, textStyles = [], numberOfLines = 1, renderAdditionalText, forwardedFSClass, testID}: DisplayNamesProps) {
function DisplayNames({accessibilityLabel, fullTitle, textStyles = [], numberOfLines = 1, renderAdditionalText, forwardedFSClass, testID, shouldParseFullTitle = true}: DisplayNamesProps) {
const {translate} = useLocalize();
const titleContainsTextAndCustomEmoji = useMemo(() => containsCustomEmoji(fullTitle) && !containsOnlyCustomEmoji(fullTitle), [fullTitle]);
const title = useMemo(() => {
if (shouldParseFullTitle) {
return StringUtils.lineBreaksToSpaces(Parser.htmlToText(fullTitle)) || translate('common.hidden');
}
return fullTitle || translate('common.hidden');
}, [fullTitle, shouldParseFullTitle, translate]);
return (
<Text
accessibilityLabel={accessibilityLabel}
Expand All @@ -21,11 +27,11 @@ function DisplayNames({accessibilityLabel, fullTitle, textStyles = [], numberOfL
>
{titleContainsTextAndCustomEmoji ? (
<TextWithEmojiFragment
message={StringUtils.lineBreaksToSpaces(Parser.htmlToText(fullTitle)) || translate('common.hidden')}
message={title}
style={textStyles}
/>
) : (
StringUtils.lineBreaksToSpaces(Parser.htmlToText(fullTitle)) || translate('common.hidden')
title
)}
{renderAdditionalText?.()}
</Text>
Expand Down
3 changes: 2 additions & 1 deletion src/components/DisplayNames/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ function DisplayNames({
shouldUseFullTitle,
displayNamesWithTooltips,
renderAdditionalText,
shouldParseFullTitle = true,
forwardedFSClass,
}: DisplayNamesProps) {
const {translate} = useLocalize();
const title = StringUtils.lineBreaksToSpaces(Parser.htmlToText(fullTitle)) || translate('common.hidden');
const title = StringUtils.lineBreaksToSpaces(shouldParseFullTitle ? Parser.htmlToText(fullTitle) : fullTitle) || translate('common.hidden');

if (!tooltipEnabled) {
return (
Expand Down
8 changes: 8 additions & 0 deletions src/components/DisplayNames/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ type DisplayNamesProps = ForwardedFSClassProps & {
/** The full title of the DisplayNames component (not split up) */
fullTitle: string;

/**
* Whether `fullTitle` should be processed through Parser.htmlToText().
* Set to true when `fullTitle` contains HTML that needs to be converted to plain text
* Set to false when `fullTitle` is already plain text or when you want to preserve
* any HTML formatting in the display.
*/
shouldParseFullTitle?: boolean;

/** Array of objects that map display names to their corresponding tooltip */
displayNamesWithTooltips?: DisplayNameWithTooltip[];

Expand Down
1 change: 1 addition & 0 deletions src/components/LHNOptionsList/OptionRowLHN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ function OptionRowLHN({
<View style={contentContainerStyles}>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.mw100, styles.overflowHidden]}>
<DisplayNames
shouldParseFullTitle={false}
accessibilityLabel={translate('accessibilityHints.chatUserDisplayNames')}
fullTitle={optionItem.text ?? ''}
displayNamesWithTooltips={optionItem.displayNamesWithTooltips ?? []}
Expand Down
1 change: 1 addition & 0 deletions src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ function MenuItem({
if (title && titleWithTooltips && Array.isArray(titleWithTooltips) && titleWithTooltips.length > 0) {
return (
<DisplayNames
shouldParseFullTitle={!shouldRenderAsHTML}
fullTitle={title}
displayNamesWithTooltips={titleWithTooltips}
tooltipEnabled
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
<CaretWrapper>
<DisplayNames
fullTitle={title}
shouldParseFullTitle={false}
displayNamesWithTooltips={displayNamesWithTooltips}
tooltipEnabled
numberOfLines={1}
Expand Down