No patch has landed yet and we've already had feedback from users (which is a good thing!) that didn't want to lose the "quick" submitter search by just typing a string and pressing <Enter> without having to wait for the autocompletion to finish.
This will also make <Enter> do something useful for input strings that have fewer than 4 characters, the autocompletion query only triggers after that. Signed-off-by: Damien Lespiau <damien.lesp...@intel.com> Acked-by: Stephen Finucane <stephen.finuc...@intel.com> --- patchwork/templates/patchwork/filters.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/patchwork/templates/patchwork/filters.html b/patchwork/templates/patchwork/filters.html index 6ab8108..1af943b 100644 --- a/patchwork/templates/patchwork/filters.html +++ b/patchwork/templates/patchwork/filters.html @@ -20,13 +20,36 @@ function filter_click() } +Selectize.define('enter_key_submit', function (options) { + var self = this; + + this.onKeyDown = (function (e) { + var original = self.onKeyDown; + + return function (e) { + original.apply(this, arguments); + + if (e.keyCode === 13 && this.$control_input.val() != '' ) + self.trigger('submit'); + }; + })(); +}); + $(document).ready(function() { $('#submitter_input').selectize({ valueField: 'pk', labelField: 'name', searchField: ['name', 'email'], + plugins: ['enter_key_submit'], maxItems: 1, persist: false, + onInitialize: function() { + this.on('submit', function() { + if (!this.items.length) + this.$input.val(this.lastValue); + this.$input.closest('form').submit(); + }, this); + }, render: { option: function(item, escape) { return '<div>' + escape(item.name) + ' <' + -- 2.1.0 _______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork