Skip to content

Commit de70ff3

Browse files
fix: display SVG emojis in the picker (#16492)
Fix #16263
1 parent 6a67e2e commit de70ff3

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

site/src/components/IconField/EmojiPicker.tsx

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import data from "@emoji-mart/data/sets/15/apple.json";
22
import EmojiMart from "@emoji-mart/react";
3-
import type { ComponentProps, FC } from "react";
3+
import {
4+
type ComponentProps,
5+
type FC,
6+
useEffect,
7+
useLayoutEffect,
8+
} from "react";
49
import icons from "theme/icons.json";
510

611
const custom = [
@@ -26,6 +31,23 @@ type EmojiPickerProps = Omit<
2631
>;
2732

2833
const EmojiPicker: FC<EmojiPickerProps> = (props) => {
34+
/**
35+
* Workaround for a bug in the emoji-mart library where custom emoji images render improperly.
36+
* Setting the image width to 100% ensures they display correctly.
37+
*
38+
* Issue: https://github.com/missive/emoji-mart/issues/805
39+
* Open PR: https://github.com/missive/emoji-mart/pull/806
40+
*/
41+
useEffect(() => {
42+
const picker = document.querySelector("em-emoji-picker")?.shadowRoot;
43+
if (!picker) {
44+
return;
45+
}
46+
const css = document.createElement("style");
47+
css.textContent = ".emoji-mart-emoji img { width: 100% }";
48+
picker.appendChild(css);
49+
}, []);
50+
2951
return (
3052
<EmojiMart
3153
theme="dark"

0 commit comments

Comments
 (0)