diff --git a/packages/react-chat/src/components/Chat/ChatInput.tsx b/packages/react-chat/src/components/Chat/ChatInput.tsx index e0312e1..03b8a51 100644 --- a/packages/react-chat/src/components/Chat/ChatInput.tsx +++ b/packages/react-chat/src/components/Chat/ChatInput.tsx @@ -11,6 +11,7 @@ import { useIdentity } from "../../contexts/identityProvider"; import { useMessengerContext } from "../../contexts/messengerProvider"; import { useModal } from "../../contexts/modalProvider"; import { useNarrow } from "../../contexts/narrowProvider"; +import { useClickOutside } from "../../hooks/useClickOutside"; import { Reply } from "../../hooks/useReply"; import { uintToImgUrl } from "../../utils/uintToImgUrl"; import { ClearBtn } from "../Form/inputStyles"; @@ -54,14 +55,8 @@ export function ChatInput({ reply, setReply }: ChatInputProps) { const inputRef = useRef(null); - useEffect(() => { - if (showEmoji) { - window.addEventListener("click", () => setShowEmoji(false)); - } - return () => { - window.removeEventListener("click", () => setShowEmoji(false)); - }; - }, [showEmoji]); + const ref = useRef(null); + useClickOutside(ref, () => setShowEmoji(false)); const image = useMemo( () => (imageUint ? uintToImgUrl(imageUint) : ""), @@ -211,7 +206,10 @@ export function ChatInput({ reply, setReply }: ChatInputProps) { return ( - + + + + { - e.stopPropagation(); - if (!disabled) { - setShowEmoji(!showEmoji); - } + onClick={() => { + if (!disabled) setShowEmoji(!showEmoji); }} disabled={disabled} > @@ -325,9 +320,15 @@ const InputWrapper = styled.div` position: relative; `; +const EmojiWrapper = styled.div` + position: absolute; + bottom: calc(100% - 6px); + right: 8px; +`; + const View = styled.div` display: flex; - align-items: center; + align-items: flex-end; padding: 6px 8px 6px 10px; position: relative; `; @@ -356,7 +357,7 @@ const Row = styled.div` const InputButtons = styled.div` display: flex; - align-items: center; + align-self: flex-end; button + button { margin-left: 4px; diff --git a/packages/react-chat/src/components/Chat/EmojiPicker.tsx b/packages/react-chat/src/components/Chat/EmojiPicker.tsx index 042c4df..46542bf 100644 --- a/packages/react-chat/src/components/Chat/EmojiPicker.tsx +++ b/packages/react-chat/src/components/Chat/EmojiPicker.tsx @@ -23,9 +23,6 @@ export function EmojiPicker({ showEmoji, addEmoji }: EmojiPickerProps) { color={theme.tertiary} emojiSize={26} style={{ - position: "absolute", - bottom: "100%", - right: "0", color: theme.secondary, height: low ? "200px" : "355px", overflow: "auto", diff --git a/packages/react-chat/src/components/Messages/MessageReactions.tsx b/packages/react-chat/src/components/Messages/MessageReactions.tsx index 15dbf44..19b13a7 100644 --- a/packages/react-chat/src/components/Messages/MessageReactions.tsx +++ b/packages/react-chat/src/components/Messages/MessageReactions.tsx @@ -21,6 +21,7 @@ export function MessageReactions({ {messageReactions.map((reaction) => (

1