Project

General

Profile

Actions

Feature #29473

closed

Submit a form with Ctrl+Enter / Command+Return

Feature #29473: Submit a form with Ctrl+Enter / Command+Return

Added by Kamil . about 8 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
UI
Target version:
Resolution:
Fixed

Description

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


Files

feature-29473.patch (1.18 KB) feature-29473.patch Mizuki ISHIKAWA, 2020-07-29 08:35
feature-29473-v2.patch (1.03 KB) feature-29473-v2.patch Mizuki ISHIKAWA, 2020-08-21 10:08
support-ajax-form.patch (1.06 KB) support-ajax-form.patch Mizuki ISHIKAWA, 2020-10-14 09:18

Related issues 3 (1 open — 2 closed)

Related to Redmine - Feature #449: Keyboard shortcutsReopenedActions
Has duplicate Redmine - Feature #34912: Save ticket by pressing keyboard keyClosedActions
Precedes Redmine - Feature #33918: Add documentation for #29473ClosedActions

Updated by Go MAEDA about 8 years ago Actions #1

Updated by Go MAEDA about 8 years ago Actions #2

  • Category set to UI

Updated by Davide Giacometti almost 8 years ago Actions #3

Hi Kamil,

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

Davide

Updated by Kamil . almost 8 years ago Actions #4

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"?

Updated by Davide Giacometti almost 8 years ago Actions #5

Redmine version?

Updated by Kamil . almost 8 years ago Actions #6

3.4.6.stable

Updated by Go MAEDA over 6 years ago Actions #7

+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.

Updated by Mizuki ISHIKAWA over 6 years ago Actions #8

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

Not tested on Windows.

Updated by Go MAEDA over 6 years ago Actions #9

  • Target version set to Candidate for next major release

+1
Nice improvement.

Updated by Go MAEDA over 6 years ago Actions #10

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

Setting the target version to 4.2.0.

Updated by Mizuki ISHIKAWA about 6 years ago Actions #11

I will attach the updated patch.

Updated by Go MAEDA about 6 years ago Actions #12

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

Updated by Mizuki ISHIKAWA about 6 years ago Actions #13

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.

Updated by Go MAEDA about 6 years ago Actions #14

  • 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.

Updated by Mischa The Evil about 6 years ago Actions #15

Updated by Mizuki ISHIKAWA about 6 years ago Actions #16

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.

Updated by Go MAEDA about 6 years ago Actions #17

Mizuki ISHIKAWA wrote:

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.

Committed the fix. Thank you.

Updated by Go MAEDA over 5 years ago Actions #18

  • Has duplicate Feature #34912: Save ticket by pressing keyboard key added
Actions

Also available in: PDF Atom