When the minLength option is set, a search occurs when it reaches the minLength. For example, if the minLength is 3, and you typed in Tommy, but then decided you wanted Bob, while you are backspacing, it performs a search at Tom, and with long search results, you have to wait until the Tom results load before typing Bob. Moving clearTimeout before checking minLength solves this issue.
// Clear out any existing timer.
clearTimeout(requestDelayTimer);
// Don't process if below minimum query length
if (query.length < plugin.options.minLength) {
plugin.list.setStatus(plugin.t('statusTooShort'));
return;
}
When the
minLength
option is set, a search occurs when it reaches theminLength
. For example, if theminLength
is 3, and you typed inTommy
, but then decided you wantedBob
, while you are backspacing, it performs a search atTom
, and with long search results, you have to wait until theTom
results load before typingBob
. MovingclearTimeout
before checkingminLength
solves this issue.