mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: display SVG emojis in the picker (#16492)
Fix https://github.com/coder/coder/issues/16263
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user