Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🔧 fix: android keyboard `@` popover issue (#2647)

Marco Beretta83bae9e9d9e1
diff --git a/client/src/hooks/Input/useTextarea.ts b/client/src/hooks/Input/useTextarea.ts
index 1da901418b..8c39e76dde 100644
--- a/client/src/hooks/Input/useTextarea.ts
+++ b/client/src/hooks/Input/useTextarea.ts
@@ -14,11 +14,6 @@ import store from '~/store';
type KeyEvent = KeyboardEvent<HTMLTextAreaElement>;
-const keyMap = {
- 50: '2',
- 192: '@',
-};
-
export default function useTextarea({
textAreaRef,
submitButtonRef,
@@ -141,35 +136,22 @@ export default function useTextarea({
assistantMap,
]);
- 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;
- if (!(text && text[text.length - 1] === '@')) {
- return;
- }
+ const handleKeyUp = useCallback(() => {
+ const text = textAreaRef.current?.value;
+ if (!(text && text[text.length - 1] === '@')) {
+ return;
+ }
- const startPos = textAreaRef.current?.selectionStart;
- if (!startPos) {
- return;
- }
+ const startPos = textAreaRef.current?.selectionStart;
+ if (!startPos) {
+ return;
+ }
- const isAtStart = startPos === 1;
- const isPrecededBySpace = textAreaRef.current?.value.charAt(startPos - 2) === ' ';
+ const isAtStart = startPos === 1;
+ const isPrecededBySpace = textAreaRef.current?.value.charAt(startPos - 2) === ' ';
- setShowMentionPopover(isAtStart || isPrecededBySpace);
- },
- [textAreaRef, setShowMentionPopover],
- );
+ setShowMentionPopover(isAtStart || isPrecededBySpace);
+ }, [textAreaRef, setShowMentionPopover]);
const handleKeyDown = useCallback(
(e: KeyEvent) => {