matchResponseProperty incorrect asynchronous responses shown #291
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.
Hi,
I have started using the autocomplete on my new site and I have found a problem where the incorrect results for the entered search term are shown. The matchResponseProperty does not correctly work. The issue can be recreated by making two remote requests for data and having the first request response after the second. For example make two requests for "Tes" and "Test", if "Test" responses first the autocomplete will show the correct results. However when the response for "Tes" arrives after, these results are shown, this is incorrect as the input box contains "Test". This issue particularly affects mobile connections with slow connections.
The error comes about because the inputPhrase is captured before the ajax request and is not reread from the input box on the ajax response. I have replaced this functionality with a simple counter "remoteRequestCount". The counter is captured into a local variable and then rechecked against the state. This also has the befits of not having the users having to include matchResponseProperty in there servers response.
I am sorry but I have only altered the source files. I am an expired developer but not in the javascript world and could not get my grunt build going in the time I had.
Thank you
Dan