Feature #29473

Submit a form with Ctrl+Enter / Command+Return

Added by Kamil . about 2 years ago. Updated 13 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:UI
Target version:4.2.0
Resolution:Fixed

Description

While editing issue, Ctrl+Enter should invoke "Submit"
While creating new issue Ctrl+Enter should invoke "Create"

feature-29473.patch Magnifier (1.18 KB) Mizuki ISHIKAWA, 2020-07-29 08:35

feature-29473-v2.patch Magnifier (1.03 KB) Mizuki ISHIKAWA, 2020-08-21 10:08

support-ajax-form.patch Magnifier (1.06 KB) Mizuki ISHIKAWA, 2020-10-14 09:18


Related issues

Related to Redmine - Feature #449: Keyboard shortcuts Reopened
Precedes Redmine - Feature #33918: Add documentation for #29473 New

Associated revisions

Revision 19986
Added by Go MAEDA about 1 month ago

Submit a form with Ctrl+Enter / Command+Return (#29473).

Patch by Mizuki ISHIKAWA.

History

#1 Updated by Go MAEDA about 2 years ago

#2 Updated by Go MAEDA about 2 years ago

  • Category set to UI

#3 Updated by Davide Giacometti almost 2 years ago

Hi Kamil,

I have added these shortcuts to my Redmine Shortcuts Plugin.
Try it if you want.

Davide

#4 Updated by Kamil . almost 2 years ago

Davide,

I've installed 0.2.0 version but it doesn't seem to work.
Both (while creating and editing) it displays browser popup "do you really want to leave this site"?

#5 Updated by Davide Giacometti almost 2 years ago

Redmine version?

#6 Updated by Kamil . almost 2 years ago

3.4.6.stable

#7 Updated by Go MAEDA 5 months ago

+1

Many apps or services such as Gitlab, GitHub, Gmail, Outlook, Slack, Facebook, and Twitter support submitting a form by hitting Ctrl+Enter / ⌘+Return. I think that a lot of users are familiar with this shortcut key.

Redmine will be able to provide consistent UI with many other apps if the key combination is supported.

#8 Updated by Mizuki ISHIKAWA 3 months ago

I have attached a patch.
Add hisSubmitAction variable to not show "do you really want to leave this site?"

Not tested on Windows.

#9 Updated by Go MAEDA 3 months ago

  • Target version set to Candidate for next major release

+1
Nice improvement.

#10 Updated by Go MAEDA 3 months ago

  • Target version changed from Candidate for next major release to 4.2.0

Setting the target version to 4.2.0.

#11 Updated by Mizuki ISHIKAWA 2 months ago

I will attach the updated patch.

#12 Updated by Go MAEDA 2 months ago

The patch can be simplified as follows.

diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 7076aabcb..825d96c88 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -851,6 +851,14 @@ function setupFilePreviewNavigation() {
   }
 }

+$(document).on('keydown', 'form textarea', function(e) {
+  // Submit the form with Ctrl + Enter or Command + Return
+  var targetForm = $(e.target).closest('form');
+  if(e.keyCode == 13 && ((e.ctrlKey && !e.metaKey) || (!e.ctrlKey && e.metaKey) && targetForm.length)) {
+    $(e.target).closest('form').find('textarea').blur().removeData('changed');
+    targetForm.submit();
+  }
+});

 function hideOnLoad() {
  • It is not necessary to process keydown events for input[type="text"] because it submits the form by pressing Enter/Return by default. The form is submitted also by Ctrl+Enter/Option+Return
  • If the keydown for input is removed, submit() can always be used. we don't have to use both click() and submit() as attachment:feature-29473-v2.patch do. Modal dialogs to add a category or a target version also works as expected

#13 Updated by Mizuki ISHIKAWA 2 months ago

Go MAEDA wrote:

The patch can be simplified as follows.

[...]

  • It is not necessary to process keydown events for input[type="text"] because it submits the form by pressing Enter/Return by default. The form is submitted also by Ctrl+Enter/Option+Return
  • If the keydown for input is removed, submit() can always be used. we don't have to use both click() and submit() as attachment:feature-29473-v2.patch do. Modal dialogs to add a category or a target version also works as expected

That looks good.

#14 Updated by Go MAEDA about 1 month ago

  • Subject changed from Handle Ctrl+Enter while editing issue to Submit a form with Ctrl+Enter / Command+Return
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you for improving Redmine.

#15 Updated by Mischa The Evil about 1 month ago

#16 Updated by Mizuki ISHIKAWA 13 days ago

For Ajax form, using this shortcut key will result in an "Invalid form authenticity token" Error.
Example: When edit an existing journal note.

I wrote a patch to solve that problem.

Also available in: Atom PDF