fix: display SVG emojis in the picker (#16492)

Fix https://github.com/coder/coder/issues/16263
This commit is contained in:
Bruno Quaresma
2025-02-07 11:48:01 -03:00
committed by GitHub
parent 6a67e2ede6
commit de70ff3206
+23 -1
View File
@@ -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 = [
@@ -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"