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

fix 15438 maintain white space in display name #15646

Merged
4 changes: 2 additions & 2 deletions src/components/DisplayNames/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class DisplayNames extends PureComponent {
// No need for any complex text-splitting, just return a simple Text component
return (
<Text
style={this.props.textStyles}
style={[...this.props.textStyles, (this.props.numberOfLines === 1 ? styles.pre : styles.preWrap)]}
numberOfLines={this.props.numberOfLines}
>
{this.props.fullTitle}
Expand Down Expand Up @@ -100,7 +100,7 @@ class DisplayNames extends PureComponent {
>
{/* // We need to get the refs to all the names which will be used to correct
the horizontal position of the tooltip */}
<Text ref={el => this.childRefs[index] = el} style={this.props.textStyles}>
<Text ref={el => this.childRefs[index] = el} style={[...this.props.textStyles, styles.preWrap]}>
{displayName}
</Text>
</Tooltip>
Expand Down
4 changes: 4 additions & 0 deletions src/components/HTMLEngineProvider/BaseHTMLEngineProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const customHTMLElementModels = {
tagName: 'email-comment',
mixedUAStyles: {whiteSpace: 'normal'},
}),
strong: defaultHTMLElementModels.span.extend({
tagName: 'strong',
mixedUAStyles: {whiteSpace: 'pre'},
}),
alex-mechler marked this conversation as resolved.
Show resolved Hide resolved
};

const defaultViewProps = {style: [styles.alignItemsStart, styles.userSelectText]};
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Header = props => (
</Text>
{/* If there's no subtitle then display a fragment to avoid an empty space which moves the main title */}
{_.isString(props.subtitle)
? Boolean(props.subtitle) && <Text style={[styles.mutedTextLabel]} numberOfLines={1}>{props.subtitle}</Text>
? Boolean(props.subtitle) && <Text style={[styles.mutedTextLabel, styles.pre]} numberOfLines={1}>{props.subtitle}</Text>
: props.subtitle}
</View>
{props.shouldShowEnvironmentBadge && (
Expand Down
6 changes: 3 additions & 3 deletions src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ const OptionRowLHN = (props) => {
: styles.sidebarLinkText;
const textUnreadStyle = optionItem.isUnread
? [textStyle, styles.sidebarLinkTextBold] : [textStyle];
const displayNameStyle = StyleUtils.combineStyles([styles.optionDisplayName, styles.optionDisplayNameCompact, ...textUnreadStyle], props.style);
const displayNameStyle = StyleUtils.combineStyles([styles.optionDisplayName, styles.optionDisplayNameCompact, styles.pre, ...textUnreadStyle], props.style);
const textPillStyle = props.isFocused
? [styles.ml1, StyleUtils.getBackgroundColorWithOpacityStyle(themeColors.icon, 0.5)]
: [styles.ml1];
const alternateTextStyle = StyleUtils.combineStyles(props.viewMode === CONST.OPTION_MODE.COMPACT
? [textStyle, styles.optionAlternateText, styles.textLabelSupporting, styles.optionAlternateTextCompact, styles.ml2]
: [textStyle, styles.optionAlternateText, styles.textLabelSupporting], props.style);
? [textStyle, styles.optionAlternateText, styles.pre, styles.textLabelSupporting, styles.optionAlternateTextCompact, styles.ml2]
: [textStyle, styles.optionAlternateText, styles.pre, styles.textLabelSupporting], props.style);
const contentContainerStyles = props.viewMode === CONST.OPTION_MODE.COMPACT
? [styles.flex1, styles.flexRow, styles.overflowHidden, styles.alignItemsCenter]
: [styles.flex1];
Expand Down
1 change: 1 addition & 0 deletions src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const MenuItem = (props) => {
(props.icon ? styles.ml3 : undefined),
(props.shouldShowBasicTitle ? undefined : styles.textStrong),
(props.interactive && props.disabled ? {...styles.disabledText, ...styles.userSelectNone} : undefined),
styles.pre,
], props.style);
const descriptionTextStyle = StyleUtils.combineStyles([
styles.textLabelSupporting,
Expand Down
4 changes: 2 additions & 2 deletions src/components/OptionRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ class OptionRow extends Component {
: styles.sidebarLinkText;
const textUnreadStyle = (this.props.boldStyle || this.props.option.boldStyle)
? [textStyle, styles.sidebarLinkTextBold] : [textStyle];
const displayNameStyle = StyleUtils.combineStyles(styles.optionDisplayName, textUnreadStyle, this.props.style);
const alternateTextStyle = StyleUtils.combineStyles(textStyle, styles.optionAlternateText, styles.textLabelSupporting, this.props.style);
const displayNameStyle = StyleUtils.combineStyles(styles.optionDisplayName, textUnreadStyle, this.props.style, styles.pre);
const alternateTextStyle = StyleUtils.combineStyles(textStyle, styles.optionAlternateText, styles.textLabelSupporting, this.props.style, styles.pre);
const contentContainerStyles = [styles.flex1];
const sidebarInnerRowStyle = StyleSheet.flatten([
styles.chatLinkRowPressable,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/DetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class DetailsPage extends React.PureComponent {
)}
</AttachmentModal>
{details.displayName && (
<Text style={[styles.textHeadline, styles.mb6]} numberOfLines={1}>
<Text style={[styles.textHeadline, styles.mb6, styles.pre]} numberOfLines={1}>
{isSMSLogin ? this.props.toLocalPhone(details.displayName) : details.displayName}
</Text>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/ReportDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class ReportDetailsPage extends Component {
displayNamesWithTooltips={displayNamesWithTooltips}
tooltipEnabled
numberOfLines={1}
textStyles={[styles.textHeadline, styles.mb2, styles.textAlignCenter]}
textStyles={[styles.textHeadline, styles.mb2, styles.textAlignCenter, styles.pre]}
shouldUseFullTitle={isChatRoom || isPolicyExpenseChat}
/>
</View>
Expand All @@ -149,6 +149,7 @@ class ReportDetailsPage extends Component {
styles.optionAlternateText,
styles.textLabelSupporting,
styles.mb2,
styles.pre,
]}
numberOfLines={1}
>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ReportSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class ReportSettingsPage extends Component {
<Text style={[styles.textLabelSupporting, styles.lh16, styles.mb1]} numberOfLines={1}>
{this.props.translate('newRoomPage.roomName')}
</Text>
<Text numberOfLines={1} style={[styles.optionAlternateText]}>
<Text numberOfLines={1} style={[styles.optionAlternateText, styles.pre]}>
{this.props.report.reportName}
</Text>
</View>
Expand All @@ -213,7 +213,7 @@ class ReportSettingsPage extends Component {
<Text style={[styles.textLabelSupporting, styles.lh16, styles.mb1]} numberOfLines={1}>
{this.props.translate('workspace.common.workspace')}
</Text>
<Text numberOfLines={1} style={[styles.optionAlternateText]}>
<Text numberOfLines={1} style={[styles.optionAlternateText, styles.pre]}>
{linkedWorkspace.name}
</Text>
</View>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const HeaderView = (props) => {
displayNamesWithTooltips={displayNamesWithTooltips}
tooltipEnabled
numberOfLines={1}
textStyles={[styles.headerText, styles.textNoWrap]}
textStyles={[styles.headerText, styles.pre]}
shouldUseFullTitle={isChatRoom || isPolicyExpenseChat}
/>
{(isChatRoom || isPolicyExpenseChat) && (
Expand All @@ -132,6 +132,7 @@ const HeaderView = (props) => {
styles.sidebarLinkText,
styles.optionAlternateText,
styles.textLabelSupporting,
styles.pre,
]}
numberOfLines={1}
>
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ParticipantLocalTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class ParticipantLocalTime extends PureComponent {
style={[
styles.chatItemComposeSecondaryRowSubText,
styles.chatItemComposeSecondaryRowOffset,
styles.pre,
]}
numberOfLines={1}
>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItemFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const ReportActionItemFragment = (props) => {
<Tooltip text={props.tooltipText}>
<Text
numberOfLines={props.isSingleLine ? 1 : undefined}
style={[styles.chatItemMessageHeaderSender]}
style={[styles.chatItemMessageHeaderSender, (props.isSingleLine ? styles.pre : styles.preWrap)]}
>
{Str.htmlDecode(props.fragment.text)}
</Text>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/InitialSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class InitialSettingsPage extends React.Component {

<Pressable style={[styles.mt1, styles.mw100]} onPress={this.openProfileSettings}>
<Tooltip text={this.props.translate('common.profile')}>
<Text style={[styles.textHeadline]} numberOfLines={1}>
<Text style={[styles.textHeadline, styles.pre]} numberOfLines={1}>
{this.props.currentUserPersonalDetails.displayName
? this.props.currentUserPersonalDetails.displayName
: Str.removeSMSDomain(this.props.session.email)}
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/WorkspaceInitialPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class WorkspaceInitialPage extends React.Component {
style={[
styles.textHeadline,
styles.alignSelfCenter,
styles.pre,
]}
>
{this.props.policy.name}
Expand Down
2 changes: 2 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ const styles = {

textHeadline: {
...headlineFont,
...whiteSpace.preWrap,
color: themeColors.heading,
fontSize: variables.fontSizeXLarge,
},
Expand Down Expand Up @@ -2888,6 +2889,7 @@ const styles = {
flexShrink: 0,
maxWidth: variables.badgeMaxWidth,
fontSize: variables.fontSizeSmall,
...whiteSpace.pre,
...spacing.ph2,
},

Expand Down
3 changes: 3 additions & 0 deletions src/styles/utilities/whiteSpace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ export default {
preWrap: {
whiteSpace: 'pre-wrap',
},
pre: {
whiteSpace: 'pre',
},
};