From 61cdc5cd66aa44bcf724e9c1a3c2f667647e555a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 13 Jan 2026 19:45:57 +0000 Subject: [PATCH] Make Enter insert newline on mobile devices On mobile devices, pressing Enter now inserts a newline (hardBreak) instead of submitting the message. This provides better UX since mobile keyboards don't have easy access to Shift+Enter for multiline input. Behavior: - Desktop: Enter submits, Shift+Enter inserts newline (unchanged) - Mobile: Enter inserts newline, Cmd/Ctrl+Enter submits - Mobile detection: Uses touch support API (ontouchstart or maxTouchPoints) Users can still submit messages on mobile using: 1. The Send button (primary method) 2. Ctrl+Enter keyboard shortcut (if available) --- src/components/editor/MentionEditor.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/editor/MentionEditor.tsx b/src/components/editor/MentionEditor.tsx index f597ba7..7fadd8a 100644 --- a/src/components/editor/MentionEditor.tsx +++ b/src/components/editor/MentionEditor.tsx @@ -667,6 +667,9 @@ export const MentionEditor = forwardRef< // Build extensions array const extensions = useMemo(() => { + // Detect mobile devices (touch support) + const isMobile = "ontouchstart" in window || navigator.maxTouchPoints > 0; + // Custom extension for keyboard shortcuts (runs before suggestion plugins) const SubmitShortcut = Extension.create({ name: "submitShortcut", @@ -677,10 +680,16 @@ export const MentionEditor = forwardRef< handleSubmitRef.current(editor); return true; }, - // Plain Enter submits (Shift+Enter handled by hardBreak for newlines) + // Plain Enter behavior depends on device Enter: ({ editor }) => { - handleSubmitRef.current(editor); - return true; + if (isMobile) { + // On mobile, Enter inserts a newline (hardBreak) + return editor.commands.setHardBreak(); + } else { + // On desktop, Enter submits the message + handleSubmitRef.current(editor); + return true; + } }, }; },