From cbc9784d213a29d34bbcd1138484e9425bd9cadd Mon Sep 17 00:00:00 2001 From: Molkobain Date: Mon, 17 Dec 2018 16:46:39 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B01882=20Internal:=20Fix=20regression=20on?= =?UTF-8?q?=20organization=20autocomplete=20(left=20menu)=20that=20could?= =?UTF-8?q?=20not=20be=20emptied?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/jquery.autocomplete.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/js/jquery.autocomplete.js b/js/jquery.autocomplete.js index 290df0976..f634dad28 100644 --- a/js/jquery.autocomplete.js +++ b/js/jquery.autocomplete.js @@ -90,6 +90,8 @@ var blockSubmit; + var bPendingRequest = false; + // prevent form submit in opera when selecting with return key navigator.userAgent.indexOf("Opera") != -1 && $(input.form).bind("submit.autocomplete", function() { if (blockSubmit) { @@ -147,15 +149,17 @@ case options.multiple && $.trim(options.multipleSeparator) == "," && KEY.COMMA: case KEY.TAB: case KEY.RETURN: + // Do not select value while background request pending + if(bPendingRequest === true) { + return false; + } + if( selectCurrent() ) { // stop default to prevent a form submit, Opera needs special handling event.preventDefault(); blockSubmit = true; return false; } - if ($(options.keyHolder).val() === "") { - return false; - } break; case KEY.ESC: @@ -367,6 +371,8 @@ function request(term, success, failure) { if (!options.matchCase) term = term.toLowerCase(); + + bPendingRequest = true; var data = cache.load(term); // recieve the cached data if (data) { @@ -436,6 +442,7 @@ function stopLoading() { $input.removeClass(options.loadingClass); + bPendingRequest = false; }; };