mirror of
https://github.com/PrimalHQ/primal-web-app.git
synced 2024-10-03 02:10:55 +00:00
Fix mention options positioning
This commit is contained in:
parent
0caa0f29bf
commit
2783819eeb
@ -280,6 +280,12 @@ const EditBox: Component<{
|
||||
|
||||
if (!isMentioning() && e.key === '@') {
|
||||
mentionCursorPosition = getCaretCoordinates(textArea, textArea.selectionStart);
|
||||
|
||||
// Ignore if `@` is a part of a word
|
||||
if (textArea.selectionStart > 0 && ![' ', '\r\n', '\r', '\n'].includes(textArea.value[textArea.selectionStart-1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setPreQuery('');
|
||||
setQuery('');
|
||||
setMentioning(true);
|
||||
|
@ -498,6 +498,12 @@ const Messages: Component = () => {
|
||||
|
||||
if (!isMentioning() && e.key === '@') {
|
||||
mentionCursorPosition = getCaretCoordinates(newMessageInput, newMessageInput.selectionStart);
|
||||
|
||||
// Ignore if `@` is a part of a word
|
||||
if (newMessageInput.selectionStart > 0 && ![' ', '\r\n', '\r', '\n'].includes(newMessageInput.value[newMessageInput.selectionStart-1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setPreQuery('');
|
||||
setQuery('');
|
||||
setMentioning(true);
|
||||
@ -733,9 +739,13 @@ const Messages: Component = () => {
|
||||
|
||||
const taRect = newMessageInput.getBoundingClientRect();
|
||||
|
||||
let newBottom = taRect.height - mentionCursorPosition.top;
|
||||
let newBottom = taRect.height - mentionCursorPosition.top + 32;
|
||||
let newLeft = mentionCursorPosition.left;
|
||||
|
||||
if (newLeft + mentionOptions.getBoundingClientRect().width > 628) {
|
||||
newLeft = 628 - mentionOptions.getBoundingClientRect().width;
|
||||
}
|
||||
|
||||
mentionOptions.style.bottom = `${newBottom}px`;
|
||||
mentionOptions.style.left = `${newLeft}px`;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user