Fix offset of chat reaction wrapper

This commit is contained in:
Alex Gleason 2023-03-20 13:57:29 -05:00
parent f8b20858a3
commit ea4f707413
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 5 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { shift, useFloating, Placement } from '@floating-ui/react';
import { shift, useFloating, Placement, offset, OffsetOptions } from '@floating-ui/react';
import clsx from 'clsx';
import React, { useEffect, useState } from 'react';
@ -44,6 +44,7 @@ interface IEmojiSelector {
placement?: Placement
/** Whether the selector should be visible. */
visible?: boolean
offsetOptions?: OffsetOptions
/** Whether to allow any emoji to be chosen. */
all?: boolean
}
@ -55,6 +56,7 @@ const EmojiSelector: React.FC<IEmojiSelector> = ({
onReact,
placement = 'top',
visible = false,
offsetOptions,
all = true,
}): JSX.Element => {
const soapboxConfig = useSoapboxConfig();
@ -64,7 +66,7 @@ const EmojiSelector: React.FC<IEmojiSelector> = ({
const { x, y, strategy, refs, update } = useFloating<HTMLElement>({
placement,
middleware: [shift()],
middleware: [offset(offsetOptions), shift()],
});
const handleExpand: React.MouseEventHandler = () => {

View File

@ -44,6 +44,7 @@ function ChatMessageReactionWrapper(props: IChatMessageReactionWrapper) {
referenceElement={referenceElement}
onReact={handleSelect}
onClose={() => setIsOpen(false)}
offsetOptions={{ mainAxis: 12, crossAxis: -10 }}
all={false}
/>
</Portal>