Doublecheck the input length at the last moment #137
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've had issues where deleting characters in the input field faster than the server is responding to queries can leave old results on screen, even if the entire field is cleared. It largely occurs when holding the backspace key and releasing either exactly when no characters exist or while the count is < the
minLength
. The issue is most noticeable if yourdata-autocomplete-delay-value
is set very low (mine is 11).Things that didn't work:
Date.now()
and verify the result being rendered is the newest based on when it started rather than was completed in async. They almost never came in out of order so that wasn't it.What did work:
replaceResults(html)
double check the input length and if it's less thanminLengthValue
delete theinnerHTML
instead of replacing it.Why it works (AFAIK):
onInputChange
when characters are deleted but redisplayed by the async query when it finishes.Example:
data-autocomplete-min-length-value="3"
data-autocomplete-delay-value="11"