Fix emoji input for messages and notes

This commit is contained in:
Bojan Mojsilovic 2024-01-08 13:34:11 +01:00
parent 2783819eeb
commit c2e050be72
2 changed files with 13 additions and 2 deletions

View File

@ -161,7 +161,12 @@ const EditBox: Component<{
return false; return false;
} }
if (!isMentioning() && !isEmojiInput() && e.key === ':' && previousChar === ' ') { if (!isMentioning() && !isEmojiInput() && e.key === ':') {
// Ignore if `@` is a part of a word
if (textArea.selectionStart > 0 && ![' ', '\r\n', '\r', '\n'].includes(textArea.value[textArea.selectionStart-1])) {
return false;
}
emojiCursorPosition = getCaretCoordinates(textArea, textArea.selectionStart); emojiCursorPosition = getCaretCoordinates(textArea, textArea.selectionStart);
setEmojiInput(true); setEmojiInput(true);
return false; return false;

View File

@ -376,6 +376,12 @@ const Messages: Component = () => {
} }
if (!isMentioning() && !isEmojiInput() && e.key === ':') { if (!isMentioning() && !isEmojiInput() && e.key === ':') {
// Ignore if `:` is a part of a word
if (newMessageInput.selectionStart > 0 && ![' ', '\r\n', '\r', '\n'].includes(newMessageInput.value[newMessageInput.selectionStart-1])) {
return false;
}
emojiCursorPosition = getCaretCoordinates(newMessageInput, newMessageInput.selectionStart); emojiCursorPosition = getCaretCoordinates(newMessageInput, newMessageInput.selectionStart);
setEmojiInput(true); setEmojiInput(true);
return false; return false;
@ -869,7 +875,7 @@ const Messages: Component = () => {
const taRect = newMessageInput.getBoundingClientRect(); const taRect = newMessageInput.getBoundingClientRect();
let newBottom = taRect.height - emojiCursorPosition.top; let newBottom = taRect.height - emojiCursorPosition.top + 32;
let newLeft = emojiCursorPosition.left; let newLeft = emojiCursorPosition.left;
emojiOptions.style.bottom = `${newBottom}px`; emojiOptions.style.bottom = `${newBottom}px`;