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: incorrect handling for composing CJK texts in Safari (#5496)

oonishi347b72e8159d4
diff --git a/client/src/hooks/Input/useTextarea.ts b/client/src/hooks/Input/useTextarea.ts
index 3a74a5ac5e..ab881d7417 100644
--- a/client/src/hooks/Input/useTextarea.ts
+++ b/client/src/hooks/Input/useTextarea.ts
@@ -191,6 +191,9 @@ export default function useTextarea({
const isNonShiftEnter = e.key === 'Enter' && !e.shiftKey;
const isCtrlEnter = e.key === 'Enter' && (e.ctrlKey || e.metaKey);
+ // NOTE: isComposing and e.key behave differently in Safari compared to other browsers, forcing us to use e.keyCode instead
+ const isComposingInput = isComposing.current || e.key === 'Process' || e.keyCode === 229;
+
if (isNonShiftEnter && filesLoading) {
e.preventDefault();
}
@@ -204,7 +207,7 @@ export default function useTextarea({
!enterToSend &&
!isCtrlEnter &&
textAreaRef.current &&
- !isComposing.current
+ !isComposingInput
) {
e.preventDefault();
insertTextAtCursor(textAreaRef.current, '\n');
@@ -212,7 +215,7 @@ export default function useTextarea({
return;
}
- if ((isNonShiftEnter || isCtrlEnter) && !isComposing.current) {
+ if ((isNonShiftEnter || isCtrlEnter) && !isComposingInput) {
const globalAudio = document.getElementById(globalAudioId) as HTMLAudioElement | undefined;
if (globalAudio) {
console.log('Unmuting global audio');