Member Settings: optional "Submit editors with Enter" (per-user, off by default).

#4236 made every multi-line editor submit only on Ctrl/Cmd+Enter (plain Enter
= newline) so titles could be multi-line, but that removed the fast
Enter-to-save title workflow some users rely on (v10 email feedback). Add a
per-user preference in the Member Settings (Change Settings) popup, saved to
profile.submitOnEnter and OFF by default: when on, plain Enter submits the card
title, description and other inlined forms, and Shift+Enter inserts a newline;
when off, behaviour is unchanged (Ctrl/Cmd+Enter saves).

The rule stays in the single pure isSubmitKey(event, {submitOnEnter}); the card
title, the card-description override and the shared client/lib/inlinedform.js
all route through it and read the preference from the current user. New toggle
+ helper + toggleSubmitOnEnter method + schema field, i18n (en, fi), and
editorSubmitKey.test.cjs extended with positive + negative opt-in cases.

Thanks to xet7 !

Related to #4236.
This commit is contained in:
Lauri Ojansivu committed 2026-07-18 18:14:33 +03:00
1 parent e0991d6602
commit bb6b0d5477
10 files changed
+103 -11

No files matched your search

+10 -6
View File
@@ -1418,7 +1418,10 @@ Template.inlinedCardDescription.events({
tpl.isOpen.set(true);
},
'keydown form textarea'(evt, tpl) {
if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) {
// Ctrl/Cmd+Enter submits by default; plain Enter when the user enabled
// "submit on Enter" in Member Settings (Shift+Enter then makes a newline).
const submitOnEnter = !!ReactiveCache.getCurrentUser()?.hasSubmitOnEnter?.();
if (isSubmitKey(evt, { submitOnEnter })) {
tpl.find('button[type=submit]').click();
}
},
@@ -1529,11 +1532,12 @@ Template.editCardTitleForm.events({
Utils.showCopied(promise, $tooltip);
},
'keydown .js-edit-card-title'(event) {
// #4236: match the card description field — Ctrl/Cmd+Enter saves; plain
// Enter (and Shift+Enter) insert a new line instead of submitting. The old
// handler submitted on any Enter without Shift, so Enter could not add a
// newline in the title.
if (isSubmitKey(event)) {
// #4236: by default Ctrl/Cmd+Enter saves; plain Enter (and Shift+Enter)
// insert a new line. A user who turns on "submit on Enter" in Member
// Settings gets plain Enter to save (Shift+Enter for a newline) instead —
// the pre-#4236 fast title-editing workflow (#6480 email feedback).
const submitOnEnter = !!ReactiveCache.getCurrentUser()?.hasSubmitOnEnter?.();
if (isSubmitKey(event, { submitOnEnter })) {
$('.js-submit-edit-card-title-form').click();
}
},
+6
View File
@@ -231,6 +231,12 @@ template(name="changeSettingsPopup")
| {{_ 'show-desktop-drag-handles'}}
if isShowDesktopDragHandles
i.fa.fa-check
li
a.js-toggle-submit-on-enter(title="{{_ 'submit-on-enter-description'}}")
i.fa.fa-level-down
| {{_ 'submit-on-enter'}}
if isSubmitOnEnter
i.fa.fa-check
unless currentUser.isWorker
li
label.bold.clear
+10
View File
@@ -322,6 +322,10 @@ Template.changeLanguagePopup.events({
});
Template.changeSettingsPopup.helpers({
isSubmitOnEnter() {
const currentUser = ReactiveCache.getCurrentUser();
return currentUser ? currentUser.hasSubmitOnEnter() : false;
},
rescueCardDescription() {
const currentUser = ReactiveCache.getCurrentUser();
if (currentUser) {
@@ -381,6 +385,12 @@ Template.changeSettingsPopup.events({
window.localStorage.setItem('showDesktopDragHandles', 'true');
}
},
'click .js-toggle-submit-on-enter'() {
// Saved to the user profile (Member Settings only; requires a logged-in user).
if (ReactiveCache.getCurrentUser()) {
Meteor.call('toggleSubmitOnEnter');
}
},
'click .js-rescue-card-description'() {
Meteor.call('toggleRescueCardDescription')
},
+6 -1
View File
@@ -16,6 +16,8 @@ import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import { EscapeActions } from '/client/lib/escapeActions';
import { ReactiveCache } from '/imports/reactiveCache';
import { isSubmitKey } from '/models/lib/editorSubmitKey';
import {
openForm,
closeForm,
@@ -77,7 +79,10 @@ Template.inlinedForm.events({
openForm(currentlyOpenedForm, tpl);
},
'keydown form textarea'(evt, tpl) {
if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) {
// Ctrl/Cmd+Enter submits by default; a user who enabled "submit on Enter"
// in Member Settings submits on plain Enter (Shift+Enter for a newline).
const submitOnEnter = !!ReactiveCache.getCurrentUser()?.hasSubmitOnEnter?.();
if (isSubmitKey(evt, { submitOnEnter })) {
tpl.find('button[type=submit]').click();
}
},
+2
View File
@@ -1290,6 +1290,8 @@
"accounts-allowUserDelete": "Allow users to self delete their account",
"hide-minicard-label-text": "Hide minicard label text",
"show-desktop-drag-handles": "Show desktop drag handles",
"submit-on-enter": "Submit editors with Enter",
"submit-on-enter-description": "When on, pressing Enter saves the card title, description and other inline editors; Shift+Enter inserts a new line. When off, Ctrl/Cmd+Enter saves and Enter inserts a new line.",
"assignee": "Assignee",
"assignees": "Assignees",
"cardAssigneesPopup-title": "Assignee",
+2
View File
@@ -1290,6 +1290,8 @@
"accounts-allowUserDelete": "Salli käyttäjien poistaa tilinsä itse",
"hide-minicard-label-text": "Piilota minikortin nimilappu teksti",
"show-desktop-drag-handles": "Näytä työpöydän vedon kahvat",
"submit-on-enter": "Lähetä editorit Enterillä",
"submit-on-enter-description": "Kun päällä, Enter tallentaa kortin otsikon, kuvauksen ja muut sisäiset editorit; Vaihto+Enter lisää rivinvaihdon. Kun pois, Ctrl/Cmd+Enter tallentaa ja Enter lisää rivinvaihdon.",
"assignee": "Käsittelijä",
"assignees": "Käsittelijät",
"cardAssigneesPopup-title": "Käsittelijä",
+16 -4
View File
@@ -7,13 +7,25 @@
// 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) {
// every multi-line editor field behaves the same.
//
// Default (submitOnEnter off): submit ONLY on Enter together with Ctrl or Cmd;
// plain Enter and Shift+Enter fall through to the textarea default (a newline).
//
// Opt-in per-user setting (submitOnEnter on, Member Settings): plain Enter
// submits and Shift+Enter inserts a newline — restoring the pre-#4236 fast
// title-editing workflow for users who prefer it, without affecting anyone else.
//
// Meteor-free and unit tested. The caller passes the current user's preference
// as opts.submitOnEnter so this stays a pure function.
function isSubmitKey(event, opts = {}) {
if (!event) return false;
const isEnter = event.keyCode === 13 || event.key === 'Enter';
if (!isEnter) return false;
if (opts.submitOnEnter) {
// plain Enter submits; Shift+Enter is a newline (Ctrl/Cmd+Enter also submits)
return !event.shiftKey;
}
return !!(event.ctrlKey || event.metaKey);
}
+14
View File
@@ -272,6 +272,15 @@ Users.attachSchema(
type: Boolean,
optional: true,
},
'profile.submitOnEnter': {
/**
* per-user preference: in multi-line editors (card title/description and
* other inlined forms) submit on plain Enter (Shift+Enter for a newline)
* instead of the default Ctrl/Cmd+Enter. Off by default. See #4236/#6480.
*/
type: Boolean,
optional: true,
},
'profile.GreyIcons': {
/**
* per-user preference to render unicode icons in grey
@@ -1409,6 +1418,11 @@ Users.helpers({
return profile.showDesktopDragHandles || false;
},
hasSubmitOnEnter() {
const profile = this.profile || {};
return profile.submitOnEnter || false;
},
hasGreyIcons() {
const profile = this.profile || {};
return profile.GreyIcons || false;
+10
View File
@@ -494,6 +494,16 @@ Meteor.methods({
user.toggleDesktopHandles(user.hasShowDesktopDragHandles());
},
// Per-user "submit editors on plain Enter" preference (Member Settings).
// Off by default; when on, plain Enter submits and Shift+Enter is a newline.
async toggleSubmitOnEnter() {
if (!this.userId) throw new Meteor.Error('not-logged-in', 'User must be logged in');
const user = await Users.findOneAsync(this.userId);
if (!user) throw new Meteor.Error('user-not-found', 'User not found');
const current = !!((user.profile || {}).submitOnEnter);
await Users.updateAsync(this.userId, { $set: { 'profile.submitOnEnter': !current } });
},
async createWorkspace(params) {
check(params, Object);
const { parentId = null, name } = params;
+27
View File
@@ -56,4 +56,31 @@ test('NEGATIVE: null / undefined event does not throw and does not submit', () =
assert.strictEqual(isSubmitKey(undefined), false);
});
// --- Per-user opt-in setting (Member Settings): submitOnEnter -----------------
// When the user turns on "submit on Enter", plain Enter submits and Shift+Enter
// makes a newline. Default (off) keeps the #4236 Ctrl/Cmd+Enter behaviour above.
test('submitOnEnter: plain Enter submits', () => {
assert.strictEqual(isSubmitKey({ keyCode: 13 }, { submitOnEnter: true }), true);
assert.strictEqual(isSubmitKey({ key: 'Enter' }, { submitOnEnter: true }), true);
});
test('submitOnEnter: Ctrl/Cmd+Enter still submits', () => {
assert.strictEqual(isSubmitKey({ keyCode: 13, ctrlKey: true }, { submitOnEnter: true }), true);
assert.strictEqual(isSubmitKey({ keyCode: 13, metaKey: true }, { submitOnEnter: true }), true);
});
test('submitOnEnter NEGATIVE: Shift+Enter does NOT submit (it is a newline)', () => {
assert.strictEqual(isSubmitKey({ keyCode: 13, shiftKey: true }, { submitOnEnter: true }), false);
});
test('submitOnEnter NEGATIVE: a non-Enter key never submits', () => {
assert.strictEqual(isSubmitKey({ keyCode: 65 }, { submitOnEnter: true }), false);
});
test('submitOnEnter defaults off: explicit false and omitted both require Ctrl/Cmd', () => {
assert.strictEqual(isSubmitKey({ keyCode: 13 }, { submitOnEnter: false }), false);
assert.strictEqual(isSubmitKey({ keyCode: 13 }, {}), false);
assert.strictEqual(isSubmitKey({ keyCode: 13 }), false);
});
console.log(`\n${passed} tests passed`);