🐛(frontend) emoji-picker fix lack of overlay

The EmojiPicker component now displays an overlay
when opened, it fixes an issue when multiple pickers
are present on the same page and we click on one of them,
the others were not closing.
This commit is contained in:
Olivier Laurendeau
2025-09-15 21:35:59 +02:00
committed by Anthony LC
parent 08f3ceaf3f
commit 9d3c1eb9d5
3 changed files with 30 additions and 3 deletions

View File

@@ -9,16 +9,18 @@ interface EmojiPickerProps {
emojiData: EmojiMartData;
onClickOutside: () => void;
onEmojiSelect: ({ native }: { native: string }) => void;
withOverlay?: boolean;
}
export const EmojiPicker = ({
emojiData,
onClickOutside,
onEmojiSelect,
withOverlay = false,
}: EmojiPickerProps) => {
const { i18n } = useTranslation();
return (
const pickerContent = (
<Box $position="absolute" $zIndex={1000} $margin="2rem 0 0 0">
<Picker
data={emojiData}
@@ -30,4 +32,27 @@ export const EmojiPicker = ({
/>
</Box>
);
if (withOverlay) {
return (
<>
{/* Overlay transparent pour fermer en cliquant à l'extérieur */}
<div
style={{
position: 'fixed',
top: 0,
left: 0,
width: '100vw',
height: '100vh',
zIndex: 999,
backgroundColor: 'transparent',
}}
onClick={onClickOutside}
/>
{pickerContent}
</>
);
}
return pickerContent;
};

View File

@@ -122,6 +122,7 @@ const CalloutComponent = ({
emojiData={emojidata}
onClickOutside={onClickOutside}
onEmojiSelect={onEmojiSelect}
withOverlay={true}
/>
)}
<Box as="p" className="inline-content" ref={contentRef} />

View File

@@ -77,10 +77,10 @@ export const DocIcon = ({
return (
<>
<BoxButton
className="--docs--doc-icon"
ref={iconRef}
onClick={toggleEmojiPicker}
$position="relative"
className="--docs--doc-icon"
color="tertiary-text"
>
{!emoji ? (
defaultIcon
@@ -112,6 +112,7 @@ export const DocIcon = ({
emojiData={emojidata}
onEmojiSelect={handleEmojiSelect}
onClickOutside={handleClickOutside}
withOverlay={true}
/>
</div>,
document.body,