Project

General

Profile

Actions

Feature #29473

closed

Submit a form with Ctrl+Enter / Command+Return

Added by Kamil . about 6 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
UI
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
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

Related to Redmine - Feature #449: Keyboard shortcutsReopened

Actions
Has duplicate Redmine - Feature #34912: Save ticket by pressing keyboard keyClosed

Actions
Precedes Redmine - Feature #33918: Add documentation for #29473New

Actions
Actions #1

Updated by Go MAEDA about 6 years ago

Actions #2

Updated by Go MAEDA about 6 years ago

  • Category set to UI
Actions #3

Updated by Davide Giacometti almost 6 years ago

Hi Kamil,

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

Davide

Actions #4

Updated by Kamil . almost 6 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"?

Actions #5

Updated by Davide Giacometti almost 6 years ago

Redmine version?

Actions #6

Updated by Kamil . almost 6 years ago

3.4.6.stable

Actions #7

Updated by Go MAEDA over 4 years 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.

Actions #8

Updated by Mizuki ISHIKAWA over 4 years ago

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

Not tested on Windows.

Actions #9

Updated by Go MAEDA about 4 years ago

  • Target version set to Candidate for next major release

+1
Nice improvement.

Actions #10

Updated by Go MAEDA about 4 years ago

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

Setting the target version to 4.2.0.

Actions #11

Updated by Mizuki ISHIKAWA about 4 years ago

I will attach the updated patch.

Actions #12

Updated by Go MAEDA about 4 years 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
Actions #13

Updated by Mizuki ISHIKAWA about 4 years 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.

Actions #14

Updated by Go MAEDA about 4 years 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.

Actions #15

Updated by Mischa The Evil about 4 years ago

Actions #16

Updated by Mizuki ISHIKAWA about 4 years 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.

Actions #17

Updated by Go MAEDA almost 4 years ago

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.

Actions #18

Updated by Go MAEDA over 3 years ago

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

Also available in: Atom PDF