Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion stylesheets/components/fun/FunEmoji.scss
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ $inline-emoji-container-name: inline-emoji;
margin-bottom: round(-0.4em + 1px, 1px);
vertical-align: baseline;
content-visibility: auto;
user-select: none;
// We want to inherit here since most usage of <Emojify> should not be
// selectable, but in cases like messages, conversation titles/descriptions,
// etc we want emoji to be selectable within the surrounding text.
// If the root `.FunInlineEmoji` element isn't selectable, then selection
// can't start on the emoji itself.
user-select: inherit;
}

.FunEmojiSelectionText {
Expand Down
3 changes: 3 additions & 0 deletions ts/components/conversation/Emojify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type Props = {
isInvisible?: boolean;
/** Allows you to customize now non-newlines are rendered. Simplest is just a <span>. */
renderNonEmoji?: RenderTextCallbackType;
selectable?: boolean;
};

const defaultRenderNonEmoji: RenderTextCallbackType = ({ text }) => text;
Expand All @@ -31,6 +32,7 @@ export function Emojify({
fontSizeOverride,
text,
renderNonEmoji = defaultRenderNonEmoji,
selectable = false,
}: Props): JSX.Element {
const emojiLocalizer = useFunEmojiLocalizer();
return (
Expand Down Expand Up @@ -59,6 +61,7 @@ export function Emojify({
aria-label={emojiLocalizer.getLocaleShortName(variantKey)}
emoji={variant}
size={fontSizeOverride}
selectable={selectable}
/>
);
}
Expand Down
1 change: 1 addition & 0 deletions ts/components/conversation/MessageTextRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ function renderText({
)}
fontSizeOverride={jumboEmojiSize}
text={text}
selectable
/>
);
}
Expand Down
2 changes: 2 additions & 0 deletions ts/components/fun/FunEmoji.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export type FunInlineEmojiProps = FunImageAriaProps &
Readonly<{
size?: number | null;
emoji: EmojiVariantData;
selectable?: boolean;
}>;

export function FunInlineEmoji(props: FunInlineEmojiProps): JSX.Element {
Expand Down Expand Up @@ -183,6 +184,7 @@ export function FunInlineEmoji(props: FunInlineEmojiProps): JSX.Element {
'--fun-emoji-sheet-x': props.emoji.sheetX,
'--fun-emoji-sheet-y': props.emoji.sheetY,
'--fun-emoji-jumbo-image': jumboImage,
...(props.selectable && { userSelect: 'text' }),
} as CSSProperties
}
/>
Expand Down