プロジェクト

全般

プロフィール

Vote #79492

完了

Submit a form with Ctrl+Enter / Command+Return

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
UI_10
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
10
version_id:
152
issue_org_id:
29473
author_id:
8238
assigned_to_id:
332
comments:
18
status_id:
5
tracker_id:
2
plus1:
2
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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


journals

--------------------------------------------------------------------------------
Hi Kamil,

I have added these shortcuts to my "Redmine Shortcuts Plugin":https://www.redmine.org/plugins/redmine_shortcuts.
Try it if you want.

Davide
--------------------------------------------------------------------------------
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"?
--------------------------------------------------------------------------------
Redmine version?
--------------------------------------------------------------------------------
3.4.6.stable
--------------------------------------------------------------------------------
+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.
--------------------------------------------------------------------------------
I have attached a patch.
Add hisSubmitAction variable to not show "do you really want to leave this site?"

Not tested on Windows.
--------------------------------------------------------------------------------
+1
Nice improvement.
--------------------------------------------------------------------------------
Setting the target version to 4.2.0.
--------------------------------------------------------------------------------
I will attach the updated patch.
--------------------------------------------------------------------------------
The patch can be simplified as follows.

<pre><code class="diff">
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() {
</code></pre>

* 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
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
Committed the patch. Thank you for improving Redmine.
--------------------------------------------------------------------------------

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

--------------------------------------------------------------------------------


related_issues

relates,Reopened,449,Keyboard shortcuts
duplicates,Closed,34912,Save ticket by pressing keyboard key
precedes,New,33918,Add documentation for #29473

Admin Redmine さんが約4年前に更新

  • カテゴリUI_10 にセット
  • 対象バージョン4.2.0_152 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0