mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
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.
21 lines
914 B
JavaScript
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 };
|