Skip to content

Commit 9a26899

Browse files
authored
Merge pull request Expensify#61111 from ChavdaSachin/fix-61030/AccountSwitcher-emojis-cut-off
Account Switcher fix emojis cut-off
2 parents fdf965c + e51ed1f commit 9a26899

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/components/AccountSwitcher.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {clearDelegatorErrors, connect, disconnect} from '@libs/actions/Delegate'
1313
import {close} from '@libs/actions/Modal';
1414
import {getLatestError} from '@libs/ErrorUtils';
1515
import {getPersonalDetailByEmail} from '@libs/PersonalDetailsUtils';
16+
import TextWithEmojiFragment from '@pages/home/report/comment/TextWithEmojiFragment';
1617
import variables from '@styles/variables';
1718
import CONST from '@src/CONST';
1819
import ONYXKEYS from '@src/ONYXKEYS';
@@ -53,6 +54,8 @@ function AccountSwitcher({isScreenFocused}: AccountSwitcherProps) {
5354

5455
const isActingAsDelegate = !!account?.delegatedAccess?.delegate;
5556
const canSwitchAccounts = delegators.length > 0 || isActingAsDelegate;
57+
const displayName = currentUserPersonalDetails?.displayName ?? '';
58+
const doesDisplayNameContainEmojis = new RegExp(CONST.REGEX.EMOJIS, CONST.REGEX.EMOJIS.flags.concat('g')).test(displayName);
5659

5760
const {shouldShowProductTrainingTooltip, renderProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext(
5861
CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.ACCOUNT_SWITCHER,
@@ -189,12 +192,21 @@ function AccountSwitcher({isScreenFocused}: AccountSwitcherProps) {
189192
/>
190193
<View style={[styles.flex1, styles.flexShrink1, styles.flexBasis0, styles.justifyContentCenter, styles.gap1]}>
191194
<View style={[styles.flexRow, styles.gap1]}>
192-
<Text
193-
numberOfLines={1}
194-
style={[styles.textBold, styles.textLarge, styles.flexShrink1, styles.lineHeightXLarge]}
195-
>
196-
{currentUserPersonalDetails?.displayName}
197-
</Text>
195+
{doesDisplayNameContainEmojis ? (
196+
<Text numberOfLines={1}>
197+
<TextWithEmojiFragment
198+
message={displayName}
199+
style={[styles.textBold, styles.textLarge, styles.flexShrink1, styles.lineHeightXLarge]}
200+
/>
201+
</Text>
202+
) : (
203+
<Text
204+
numberOfLines={1}
205+
style={[styles.textBold, styles.textLarge, styles.flexShrink1, styles.lineHeightXLarge]}
206+
>
207+
{displayName}
208+
</Text>
209+
)}
198210
{!!canSwitchAccounts && (
199211
<View style={styles.justifyContentCenter}>
200212
<Icon

0 commit comments

Comments
 (0)