fix(comments): attach code comments on Enter

Code comments required Cmd/Ctrl+Enter while quotes and browser annotations used Enter. Align desktop submission and its placeholder, preserve Shift+Enter line breaks and mobile keyboard behavior.

Validated UI type-check, UI lint, and six existing IME checks. Lint reports one existing warning in MobileChangesSurface. In-app browser validation was unavailable.
This commit is contained in:
Bohdan Triapitsyn
2026-09-09 17:41:14 +03:00
parent d9ac3192d0
commit 0ddd994f98
@@ -39,7 +39,7 @@ export function InlineCommentInput({
const { isMobile } = useDeviceInfo(); const { isMobile } = useDeviceInfo();
const [text, setText] = React.useState(initialText); const [text, setText] = React.useState(initialText);
const textareaRef = useRef<HTMLTextAreaElement>(null); const textareaRef = useRef<HTMLTextAreaElement>(null);
const saveShortcut = formatShortcutForDisplay('mod+enter'); const saveShortcut = formatShortcutForDisplay('enter');
void isEditing; void isEditing;
const handleTextChange = (value: string) => { const handleTextChange = (value: string) => {
@@ -124,9 +124,9 @@ export function InlineCommentInput({
const handleKeyDown = (e: React.KeyboardEvent) => { const handleKeyDown = (e: React.KeyboardEvent) => {
if (isIMECompositionEvent(e)) return; if (isIMECompositionEvent(e)) return;
// As the placeholder promises: Cmd/Ctrl+Enter attaches, plain Enter // Desktop Enter attaches; Shift+Enter and mobile Enter break the line.
// breaks the line, Escape cancels. // Keep Cmd/Ctrl+Enter available for hardware keyboards on mobile.
if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') { if (e.key === 'Enter' && !e.shiftKey && (!isMobile || e.metaKey || e.ctrlKey)) {
e.preventDefault(); e.preventDefault();
save(); save();
} else if (e.key === 'Escape') { } else if (e.key === 'Escape') {