diff mbox

[49/51] filters: Submit the form when <Enter> is pressed on a closed submitter field

Message ID 1440440620-25937-50-git-send-email-damien.lespiau@intel.com
State Changes Requested
Headers show

Commit Message

Damien Lespiau Aug. 24, 2015, 6:23 p.m. UTC
<Enter> when an element of the form is focused should submit the form.
Before this patch, when <Enter> was pressed on the submitter button,
nothing would happen.

So, we tweak our <Enter> handling on the submitter input a bit more:
<Enter> can be used to select the submitter from the autocompletion
list, but, when pressed a second time (ie. when the autocompletion
option has be selected and the dropdown isn't shown), we submit the
form.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 patchwork/templates/patchwork/filters.html | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/patchwork/templates/patchwork/filters.html b/patchwork/templates/patchwork/filters.html
index 1af943b..fe0c9b8 100644
--- a/patchwork/templates/patchwork/filters.html
+++ b/patchwork/templates/patchwork/filters.html
@@ -27,9 +27,11 @@  Selectize.define('enter_key_submit', function (options) {
         var original = self.onKeyDown;
 
         return function (e) {
+            var wasOpened = this.isOpen;
             original.apply(this, arguments);
 
-            if (e.keyCode === 13 && this.$control_input.val() != '' )
+            if (e.keyCode === 13 &&
+                (this.$control_input.val() != '' || !wasOpened))
                 self.trigger('submit');
         };
     })();