Files
wekan/models/lib/editorSubmitKey.js
T
Lauri Ojansivu a9a5ac7a07 Fix #4236: Enter adds a new line in the card title (consistent with description)
The card title textarea submitted on plain Enter (only Shift+Enter made a new
line), while the card description textarea and the shared inlinedForm insert a
new line on plain Enter and only save on Ctrl/Cmd+Enter. So Enter could not add
a new line in the title, an inconsistent experience.

The title keydown handler now uses a shared, Meteor-free rule isSubmitKey()
(models/lib/editorSubmitKey.js): submit ONLY on Enter together with Ctrl or Cmd;
plain Enter and Shift+Enter fall through to the textarea default (a new line).
This matches the description field exactly. Unit tested (positive + negative) in
tests/editorSubmitKey.test.cjs.

Thanks to listenerri and xet7.
2026-07-09 09:45:53 +03:00

21 lines
914 B
JavaScript

'use strict';
// #4236 "The processing strategy for the enter key is different". The card
// TITLE textarea submitted on PLAIN Enter (only Shift+Enter made a newline),
// while the card DESCRIPTION textarea — and the shared inlinedForm — insert a
// newline on plain Enter and only submit on Ctrl/Cmd+Enter. That inconsistency
// meant Enter could not add a new line in the title.
//
// isSubmitKey centralizes the "does this keydown submit the editor?" rule so
// every multi-line editor field behaves the same: submit ONLY on Enter together
// with Ctrl or Cmd; plain Enter and Shift+Enter fall through to the textarea
// default (a newline). Meteor-free and unit tested.
function isSubmitKey(event) {
if (!event) return false;
const isEnter = event.keyCode === 13 || event.key === 'Enter';
if (!isEnter) return false;
return !!(event.ctrlKey || event.metaKey);
}
module.exports = { isSubmitKey };