]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
filters: Submit the form when <Enter> is pressed on a closed submitter field
authorDamien Lespiau <damien.lespiau@intel.com>
Mon, 24 Aug 2015 16:49:52 +0000 (17:49 +0100)
committerStephen Finucane <stephen.finucane@intel.com>
Thu, 5 Nov 2015 03:56:27 +0000 (03:56 +0000)
<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

index 1af943b9ebe1b7358378b45e31227e12d7de6411..fe0c9b85f8e995c7e88b1fda34a19250b940b8a9 100644 (file)
@@ -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');
         };
     })();