Skip to content

Commit ac47966

Browse files
committed
Add optional userSelect property to FunEmoji and enable in MessageTextRenderer. Allows user text selection to start on an emoji. Fixes #7206
1 parent ed76a95 commit ac47966

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

ts/components/conversation/Emojify.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type Props = {
2323
isInvisible?: boolean;
2424
/** Allows you to customize now non-newlines are rendered. Simplest is just a <span>. */
2525
renderNonEmoji?: RenderTextCallbackType;
26+
selectable?: boolean;
2627
};
2728

2829
const defaultRenderNonEmoji: RenderTextCallbackType = ({ text }) => text;
@@ -31,6 +32,7 @@ export function Emojify({
3132
fontSizeOverride,
3233
text,
3334
renderNonEmoji = defaultRenderNonEmoji,
35+
selectable = false,
3436
}: Props): JSX.Element {
3537
const emojiLocalizer = useFunEmojiLocalizer();
3638
return (
@@ -59,6 +61,7 @@ export function Emojify({
5961
aria-label={emojiLocalizer.getLocaleShortName(variantKey)}
6062
emoji={variant}
6163
size={fontSizeOverride}
64+
selectable={selectable}
6265
/>
6366
);
6467
}

ts/components/conversation/MessageTextRenderer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ function renderText({
429429
)}
430430
fontSizeOverride={jumboEmojiSize}
431431
text={text}
432+
selectable
432433
/>
433434
);
434435
}

ts/components/fun/FunEmoji.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export type FunInlineEmojiProps = FunImageAriaProps &
121121
Readonly<{
122122
size?: number | null;
123123
emoji: EmojiVariantData;
124+
selectable?: boolean;
124125
}>;
125126

126127
export function FunInlineEmoji(props: FunInlineEmojiProps): JSX.Element {
@@ -162,6 +163,7 @@ export function FunInlineEmoji(props: FunInlineEmojiProps): JSX.Element {
162163
'--fun-emoji-sheet-x': props.emoji.sheetX,
163164
'--fun-emoji-sheet-y': props.emoji.sheetY,
164165
'--fun-emoji-jumbo-image': `url(${emojiJumboUrl})`,
166+
...(props.selectable && { userSelect: 'text' }),
165167
} as CSSProperties
166168
}
167169
/>

0 commit comments

Comments
 (0)