Skip to content

Commit

Permalink
fix: adjust emoji picker position calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
olafsulich committed Dec 17, 2024
1 parent cb70764 commit e26559c
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ interface EmojiPickerParams {
onEmojiPicked: (emoji: string) => void;
}

const TRIGGER_WIDTH = 40;
const TRIGGER_HEIGHT = 32;
const Y_OFFSET = 8;

export const useEmojiPicker = ({wrapperRef, onEmojiPicked}: EmojiPickerParams) => {
const [open, setOpen] = useState(false);

Expand All @@ -43,7 +47,7 @@ export const useEmojiPicker = ({wrapperRef, onEmojiPicked}: EmojiPickerParams) =
const handleToggle = (event: MouseEvent<HTMLButtonElement>) => {
const rect = event.currentTarget.getBoundingClientRect();
// eslint-disable-next-line id-length
emojiPickerPosition.current = {x: rect.x, y: rect.y};
emojiPickerPosition.current = {x: rect.x + TRIGGER_WIDTH, y: rect.y - TRIGGER_HEIGHT - Y_OFFSET};
setOpen(prev => !prev);
};

Expand Down

0 comments on commit e26559c

Please sign in to comment.