|
@@ -1,8 +1,11 @@
|
|
|
-import React, { FC } from 'react';
|
|
|
|
|
|
|
+import React, { FC, useState } from 'react';
|
|
|
|
|
+
|
|
|
import { Picker } from 'emoji-mart';
|
|
import { Picker } from 'emoji-mart';
|
|
|
import i18n from 'i18next';
|
|
import i18n from 'i18next';
|
|
|
import { Modal } from 'reactstrap';
|
|
import { Modal } from 'reactstrap';
|
|
|
|
|
+
|
|
|
import { isDarkMode } from '~/client/util/color-scheme';
|
|
import { isDarkMode } from '~/client/util/color-scheme';
|
|
|
|
|
+
|
|
|
import EmojiPickerHelper from './EmojiPickerHelper';
|
|
import EmojiPickerHelper from './EmojiPickerHelper';
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
@@ -19,6 +22,7 @@ const EmojiPicker: FC<Props> = (props: Props) => {
|
|
|
onClose, emojiSearchText, emojiPickerHelper, isOpen,
|
|
onClose, emojiSearchText, emojiPickerHelper, isOpen,
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
+ const [style, setStyle] = useState({});
|
|
|
// Set search emoji input and trigger search
|
|
// Set search emoji input and trigger search
|
|
|
const searchEmoji = () => {
|
|
const searchEmoji = () => {
|
|
|
if (emojiSearchText !== null) {
|
|
if (emojiSearchText !== null) {
|
|
@@ -28,6 +32,8 @@ const EmojiPicker: FC<Props> = (props: Props) => {
|
|
|
const event = new Event('input', { bubbles: true });
|
|
const event = new Event('input', { bubbles: true });
|
|
|
input.dispatchEvent(event);
|
|
input.dispatchEvent(event);
|
|
|
input.focus();
|
|
input.focus();
|
|
|
|
|
+ const emojiPickerHeight = window.document.querySelector('[id^="emoji-mart-search"]')?.clientHeight;
|
|
|
|
|
+ setStyle(emojiPickerHelper.getCursorCoords(emojiPickerHeight));
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -84,7 +90,7 @@ const EmojiPicker: FC<Props> = (props: Props) => {
|
|
|
const translation = getEmojiTranslation();
|
|
const translation = getEmojiTranslation();
|
|
|
const theme = isDarkMode() ? 'dark' : 'light';
|
|
const theme = isDarkMode() ? 'dark' : 'light';
|
|
|
|
|
|
|
|
- return (
|
|
|
|
|
|
|
+ return Object.keys(style).length !== 0 ? (
|
|
|
<Modal isOpen={isOpen} toggle={onClose} onOpened={searchEmoji}>
|
|
<Modal isOpen={isOpen} toggle={onClose} onOpened={searchEmoji}>
|
|
|
<Picker
|
|
<Picker
|
|
|
onSelect={selectEmoji}
|
|
onSelect={selectEmoji}
|
|
@@ -95,7 +101,7 @@ const EmojiPicker: FC<Props> = (props: Props) => {
|
|
|
theme={theme}
|
|
theme={theme}
|
|
|
/>
|
|
/>
|
|
|
</Modal>
|
|
</Modal>
|
|
|
- );
|
|
|
|
|
|
|
+ ) : <></>;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export default EmojiPicker;
|
|
export default EmojiPicker;
|