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: Improve Mobile Chat Focus Detection and Navigation (#10125)

Danny Avilac6020881782e
diff --git a/client/src/hooks/Chat/useFocusChatEffect.ts b/client/src/hooks/Chat/useFocusChatEffect.ts
index fefb2c9584..17c41fef01 100644
--- a/client/src/hooks/Chat/useFocusChatEffect.ts
+++ b/client/src/hooks/Chat/useFocusChatEffect.ts
@@ -12,12 +12,22 @@ export default function useFocusChatEffect(textAreaRef: React.RefObject<HTMLText
`Focusing textarea on location state change: ${location.pathname}`,
);
- /** Check if the device is not a touchscreen */
- if (!window.matchMedia?.('(pointer: coarse)').matches) {
- textAreaRef.current?.focus();
+ const hasCoarsePointer = window.matchMedia?.('(pointer: coarse)').matches;
+ const hasHover = window.matchMedia?.('(hover: hover)').matches;
+
+ const path = `${location.pathname}${window.location.search ?? ''}`;
+ /* Early return if mobile-like: has coarse pointer OR lacks hover */
+ if (hasCoarsePointer || !hasHover) {
+ navigate(path, {
+ replace: true,
+ state: {},
+ });
+ return;
}
- navigate(`${location.pathname}${window.location.search ?? ''}`, {
+ textAreaRef.current?.focus();
+
+ navigate(path, {
replace: true,
state: {},
});