Skip to content

fix: display SVG emojis in the picker #16492

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

Merged
merged 3 commits into from
Feb 7, 2025
Merged
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
24 changes: 23 additions & 1 deletion site/src/components/IconField/EmojiPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import data from "@emoji-mart/data/sets/15/apple.json";
import EmojiMart from "@emoji-mart/react";
import type { ComponentProps, FC } from "react";
import {
type ComponentProps,
type FC,
useEffect,
useLayoutEffect,
} from "react";
import icons from "theme/icons.json";

const custom = [
Expand All @@ -26,6 +31,23 @@ type EmojiPickerProps = Omit<
>;

const EmojiPicker: FC<EmojiPickerProps> = (props) => {
/**
* Workaround for a bug in the emoji-mart library where custom emoji images render improperly.
* Setting the image width to 100% ensures they display correctly.
*
* Issue: https://github.com/missive/emoji-mart/issues/805
* Open PR: https://github.com/missive/emoji-mart/pull/806
*/
useEffect(() => {
const picker = document.querySelector("em-emoji-picker")?.shadowRoot;
if (!picker) {
return;
}
const css = document.createElement("style");
css.textContent = ".emoji-mart-emoji img { width: 100% }";
picker.appendChild(css);
}, []);

return (
<EmojiMart
theme="dark"
Expand Down
Loading