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

Create different files for HTML Render and fix scroll width #27769

Merged
merged 10 commits into from
Sep 22, 2023
20 changes: 5 additions & 15 deletions src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ import variables from '../styles/variables';
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;
import MenuItemRenderHTMLTitle from './MenuItemRenderHTMLTitle';

const propTypes = menuItemPropTypes;

Expand Down Expand Up @@ -251,16 +247,10 @@ const MenuItem = React.forwardRef((props, ref) => {
</Text>
)}
<View style={[styles.flexRow, styles.alignItemsCenter]}>
{Boolean(props.title) &&
(Boolean(props.shouldRenderAsHTML) || (Boolean(props.shouldParseTitle) && Boolean(html.length))) &&
(isNative ? (
<RenderHTML html={getProcessedTitle} />
) : (
<View style={styles.chatItemMessage}>
<RenderHTML html={getProcessedTitle} />
</View>
))}
{!props.shouldRenderAsHTML && !html.length && Boolean(props.title) && (
{Boolean(props.title) && (Boolean(props.shouldRenderAsHTML) || (Boolean(props.shouldParseTitle) && Boolean(html.length))) && (
<MenuItemRenderHTMLTitle title={getProcessedTitle} />
)}
{!props.shouldRenderAsHTML && !props.shouldParseTitle && Boolean(props.title) && (
<Text
style={titleTextStyle}
numberOfLines={props.numberOfLinesTitle || undefined}
Expand Down
23 changes: 23 additions & 0 deletions src/components/MenuItemRenderHTMLTitle/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import {View} from 'react-native';
import styles from '../../styles/styles';
import RenderHTML from '../RenderHTML';
import menuItemRenderHTMLTitlePropTypes from './propTypes';

const propTypes = menuItemRenderHTMLTitlePropTypes;

const defaultProps = {};

function MenuItemRenderHTMLTitle(props) {
return (
<View style={styles.chatItemMessage}>
jeet-dhandha marked this conversation as resolved.
Show resolved Hide resolved
<RenderHTML html={props.title} />
</View>
);
}

MenuItemRenderHTMLTitle.propTypes = propTypes;
MenuItemRenderHTMLTitle.defaultProps = defaultProps;
MenuItemRenderHTMLTitle.displayName = 'MenuItemRenderHTMLTitle';

export default MenuItemRenderHTMLTitle;
17 changes: 17 additions & 0 deletions src/components/MenuItemRenderHTMLTitle/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import RenderHTML from '../RenderHTML';
import menuItemRenderHTMLTitlePropTypes from './propTypes';

const propTypes = menuItemRenderHTMLTitlePropTypes;

const defaultProps = {};

function MenuItemRenderHTMLTitle(props) {
return <RenderHTML html={props.title} />;
}

MenuItemRenderHTMLTitle.propTypes = propTypes;
MenuItemRenderHTMLTitle.defaultProps = defaultProps;
MenuItemRenderHTMLTitle.displayName = 'MenuItemRenderHTMLTitle';

export default MenuItemRenderHTMLTitle;
8 changes: 8 additions & 0 deletions src/components/MenuItemRenderHTMLTitle/propTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import PropTypes from 'prop-types';

const propTypes = {
/** Processed title to display for the MenuItem */
title: PropTypes.string.isRequired,
};

export default propTypes;
Loading