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:
@@ -39,7 +39,7 @@ export function InlineCommentInput({
|
||||
const { isMobile } = useDeviceInfo();
|
||||
const [text, setText] = React.useState(initialText);
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||
const saveShortcut = formatShortcutForDisplay('mod+enter');
|
||||
const saveShortcut = formatShortcutForDisplay('enter');
|
||||
void isEditing;
|
||||
|
||||
const handleTextChange = (value: string) => {
|
||||
@@ -124,9 +124,9 @@ export function InlineCommentInput({
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
if (isIMECompositionEvent(e)) return;
|
||||
|
||||
// As the placeholder promises: Cmd/Ctrl+Enter attaches, plain Enter
|
||||
// breaks the line, Escape cancels.
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
|
||||
// Desktop Enter attaches; Shift+Enter and mobile Enter break the line.
|
||||
// Keep Cmd/Ctrl+Enter available for hardware keyboards on mobile.
|
||||
if (e.key === 'Enter' && !e.shiftKey && (!isMobile || e.metaKey || e.ctrlKey)) {
|
||||
e.preventDefault();
|
||||
save();
|
||||
} else if (e.key === 'Escape') {
|
||||
|
||||
Reference in New Issue
Block a user