From 517e568e5abd07e0d898af523953b539db004b23 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Mon, 23 Mar 2020 23:29:21 +1100 Subject: [PATCH] MDL-68196 core: not expand autocomplete elements too soon on IE --- lib/amd/build/form-autocomplete.min.js | Bin 11333 -> 11568 bytes lib/amd/build/form-autocomplete.min.js.map | Bin 75824 -> 77134 bytes lib/amd/src/form-autocomplete.js | 16 +++++++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/amd/build/form-autocomplete.min.js b/lib/amd/build/form-autocomplete.min.js index 7de1001e137579569f611b2bb2af0f8af4b656af..9c07fddfb906052b405e765a374c41f268a939ea 100644 GIT binary patch delta 272 zcmXYsPfEi;97YKi>87}_MT8<|CY2c&hPn=OgSzWNbRm<;pH7-gB$;UzAxls2yGX?| zxDq^sC-4X+)b-!17C+Nkt|}0#cT&(Xz6MA4HlCgIEUu delta 221 zcmdlGbu?mwkJ99IN~$7>n$=~AMG6_Vd8IiyI+?bLhB{f3pDQV5}N=q_x^sOQ$3QhoA+Nb$)lqlEc9 zTy$I=eI0e&9UVQZTsDh`-e(5t5Sknwxs1_s^1nzmMH5$`KF4$?5b12{45C~>Cgp)d zoL#Cskj+yI0?7q?0Erw|Um%(58U`c_TwQcL9rIoNfox}w0w<`$gf@pqRx)zsnK+e# zv>BOfz7>_v$YpE_;hULm4vrDyW6H|foSmgM!7I2VzbI9qBqLR!EHS4vRUtnO%t^~k z%}G&6ELO-YDOSiyEG~ga>nN0Gq~;;1NKeenD^^I$PcAKh@I`KN z!y1;!34d88^B&WlUdO@6G2N1z(R%Xwlfs+(erfYgSLR^UnS5adiW(l6!1O*2M(4=~ zF0)U+!oip`IpGJ#^c7r;+Fpf)JQDL#a#D*lCMULt0!29{Z>SRn(I89g!OG^H Y6`efqtl;GO15%Se9N^s!be(_#0I;&8E&u=k delta 170 zcmX?ii)F(FmJI@->^km_j-ELloBxO2XVxip(s6cltOAkF9zep-#TQ5#xr6~pQx_K< zPe&6Mf3ReR`{dn`w$w^J|NX$#gNiCXecwS^O|9ip7{cG8` K%keTAC;$K%&pMX? diff --git a/lib/amd/src/form-autocomplete.js b/lib/amd/src/form-autocomplete.js index 2cffd175e61..4738bb6e48e 100644 --- a/lib/amd/src/form-autocomplete.js +++ b/lib/amd/src/form-autocomplete.js @@ -834,6 +834,12 @@ function($, log, str, templates, notification, LoadingIcon) { }); // Whenever the input field changes, update the suggestion list. if (options.showSuggestions) { + // Store the value of the field as its last value, when the field gains focus. + inputElement.on('focus', function(e) { + var query = $(e.currentTarget).val(); + $(e.currentTarget).data('last-value', query); + }); + // If this field uses ajax, set it up. if (options.ajax) { require([options.ajax], function(ajaxHandler) { @@ -893,7 +899,15 @@ function($, log, str, templates, notification, LoadingIcon) { }; // Trigger an ajax update after the text field value changes. - inputElement.on("input", throttledHandler); + inputElement.on('input', function(e) { + var query = $(e.currentTarget).val(); + var last = $(e.currentTarget).data('last-value'); + // IE11 fires many more input events than required - even when the value has not changed. + if (last !== query) { + throttledHandler(e); + } + $(e.currentTarget).data('last-value', query); + }); }); } else { inputElement.on('input', function(e) { -- 2.43.0