From 154e9679b70b4e2ce04d83d41685f808af07c818 Mon Sep 17 00:00:00 2001 From: Bojan Mojsilovic Date: Wed, 27 Dec 2023 17:09:07 +0100 Subject: [PATCH] Fix emoji & mention selector menu positioning in note editor --- src/components/NewNote/EditBox/EditBox.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/NewNote/EditBox/EditBox.tsx b/src/components/NewNote/EditBox/EditBox.tsx index 983f22c..da35a37 100644 --- a/src/components/NewNote/EditBox/EditBox.tsx +++ b/src/components/NewNote/EditBox/EditBox.tsx @@ -576,7 +576,13 @@ const EditBox: Component<{ const taRect = textArea.getBoundingClientRect(); const wRect = editWrap.getBoundingClientRect(); - let newTop = taRect.top - wRect.top + mentionCursorPosition.top + 22; + let mTop = mentionCursorPosition.top; + + if (textArea.scrollTop > 0) { + mTop -= textArea.scrollTop; + } + + let newTop = taRect.top - wRect.top + mTop + 22; let newLeft = mentionCursorPosition.left + 16; if (newTop > document.documentElement.clientHeight - 200) { @@ -595,7 +601,13 @@ const EditBox: Component<{ const taRect = textArea.getBoundingClientRect(); const wRect = editWrap.getBoundingClientRect(); - let newTop = taRect.top - wRect.top + emojiCursorPosition.top + 22; + let mTop = emojiCursorPosition.top; + + if (textArea.scrollTop > 0) { + mTop -= textArea.scrollTop; + } + + let newTop = taRect.top - wRect.top + mTop + 22; let newLeft = emojiCursorPosition.left; if (newTop > document.documentElement.clientHeight - 200) {