Feature #29473
Submit a form with Ctrl+Enter / Command+Return
Status: | Closed | Start date: | ||
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | % 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"
Related issues
Associated revisions
Submit a form with Ctrl+Enter / Command+Return (#29473).
Patch by Mizuki ISHIKAWA.
"Invalid form authenticity token" error when submitting an Ajax form with Ctrl+Enter (#29473).
Patch by Mizuki ISHIKAWA.
History
#1
Updated by Go MAEDA over 2 years ago
- Related to Feature #449: Keyboard shortcuts added
#2
Updated by Go MAEDA over 2 years ago
- Category set to UI
#3
Updated by Davide Giacometti about 2 years ago
#4
Updated by Kamil . about 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 about 2 years ago
Redmine version?
#6
Updated by Kamil . about 2 years ago
3.4.6.stable
#7
Updated by Go MAEDA 8 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 6 months ago
- File feature-29473.patch
added
I have attached a patch.
Add hisSubmitAction variable to not show "do you really want to leave this site?"
Not tested on Windows.
#11
Updated by Mizuki ISHIKAWA 5 months ago
- File feature-29473-v2.patch
added
I will attach the updated patch.
#12
Updated by Go MAEDA 5 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 bothclick()
andsubmit()
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 5 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 bothclick()
andsubmit()
as attachment:feature-29473-v2.patch do. Modal dialogs to add a category or a target version also works as expected
That looks good.
#15
Updated by Mischa The Evil 5 months ago
- Precedes Feature #33918: Add documentation for #29473 added
#16
Updated by Mizuki ISHIKAWA 3 months ago
- File support-ajax-form.patch
added
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.