diff --git a/src/components/MenuItem.js b/src/components/MenuItem.js index c8906889612f..bb4eeb7a18ac 100644 --- a/src/components/MenuItem.js +++ b/src/components/MenuItem.js @@ -1,5 +1,5 @@ import _ from 'underscore'; -import React, {useEffect} from 'react'; +import React, {useEffect, useMemo} from 'react'; import {View} from 'react-native'; import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import Text from './Text'; @@ -25,6 +25,10 @@ import * as Session from '../libs/actions/Session'; import Hoverable from './Hoverable'; import useWindowDimensions from '../hooks/useWindowDimensions'; import RenderHTML from './RenderHTML'; +import getPlatform from '../libs/getPlatform'; + +const platform = getPlatform(); +const isNative = platform === CONST.PLATFORM.IOS || platform === CONST.PLATFORM.ANDROID; const propTypes = menuItemPropTypes; @@ -119,6 +123,18 @@ const MenuItem = React.forwardRef((props, ref) => { titleRef.current = props.title; }, [props.title, props.shouldParseTitle]); + const getProcessedTitle = useMemo(() => { + if (props.shouldRenderAsHTML) { + return convertToLTR(props.title); + } + + if (props.shouldParseTitle) { + return html; + } + + return ''; + }, [props.title, props.shouldRenderAsHTML, props.shouldParseTitle, html]); + return ( {(isHovered) => ( @@ -235,10 +251,15 @@ const MenuItem = React.forwardRef((props, ref) => { )} - {Boolean(props.title) && Boolean(props.shouldRenderAsHTML) && } - - {Boolean(props.shouldParseTitle) && Boolean(html.length) && !props.shouldRenderAsHTML && ${html}`} />} - + {Boolean(props.title) && + (Boolean(props.shouldRenderAsHTML) || (Boolean(props.shouldParseTitle) && Boolean(html.length))) && + (isNative ? ( + + ) : ( + + + + ))} {!props.shouldRenderAsHTML && !html.length && Boolean(props.title) && ( { {convertToLTR(props.title)} )} - {Boolean(props.shouldShowTitleIcon) && (