mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 17:30:16 +01:00
🔧 fix: android keyboard @ popover issue (#2647)
This commit is contained in:
parent
6ba7f60eec
commit
83bae9e9d9
1 changed files with 13 additions and 31 deletions
|
|
@ -14,11 +14,6 @@ import store from '~/store';
|
||||||
|
|
||||||
type KeyEvent = KeyboardEvent<HTMLTextAreaElement>;
|
type KeyEvent = KeyboardEvent<HTMLTextAreaElement>;
|
||||||
|
|
||||||
const keyMap = {
|
|
||||||
50: '2',
|
|
||||||
192: '@',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function useTextarea({
|
export default function useTextarea({
|
||||||
textAreaRef,
|
textAreaRef,
|
||||||
submitButtonRef,
|
submitButtonRef,
|
||||||
|
|
@ -141,18 +136,7 @@ export default function useTextarea({
|
||||||
assistantMap,
|
assistantMap,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const handleKeyUp = useCallback(
|
const handleKeyUp = useCallback(() => {
|
||||||
(e: KeyEvent) => {
|
|
||||||
let normalizedKey = e.key;
|
|
||||||
|
|
||||||
if (!normalizedKey || normalizedKey === 'Unidentified') {
|
|
||||||
normalizedKey = keyMap[e.keyCode] || normalizedKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (normalizedKey !== '@' && normalizedKey !== '2') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const text = textAreaRef.current?.value;
|
const text = textAreaRef.current?.value;
|
||||||
if (!(text && text[text.length - 1] === '@')) {
|
if (!(text && text[text.length - 1] === '@')) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -167,9 +151,7 @@ export default function useTextarea({
|
||||||
const isPrecededBySpace = textAreaRef.current?.value.charAt(startPos - 2) === ' ';
|
const isPrecededBySpace = textAreaRef.current?.value.charAt(startPos - 2) === ' ';
|
||||||
|
|
||||||
setShowMentionPopover(isAtStart || isPrecededBySpace);
|
setShowMentionPopover(isAtStart || isPrecededBySpace);
|
||||||
},
|
}, [textAreaRef, setShowMentionPopover]);
|
||||||
[textAreaRef, setShowMentionPopover],
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleKeyDown = useCallback(
|
const handleKeyDown = useCallback(
|
||||||
(e: KeyEvent) => {
|
(e: KeyEvent) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue