Created
December 13, 2012 03:47
-
-
Save ngokevin/4273860 to your computer and use it in GitHub Desktop.
Why search suggestions weren't working on touch devices (bug 818013)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The problem was that setInterval would fire off multiple duplicate requests per | |
second. On each subsequent request would abort the previous request in | |
processRequest. ajaxCache would store the arguments in the first requests and | |
not serve the subsequent ones. To handle this, we keep track of the previous | |
search and only send an ajaxCache request if the search is different from the | |
previous one. This prevents multiple duplicate requests from blocking each | |
other by only having one of them be able to make the request. | |
There is still the problem of backspacing in search suggestions. On each letter | |
I add to my search query, an ajaxCache request is fired off. As I add more | |
letters to reach my desired query, ajaxCache remembers each substring of the | |
query as I typed it. And process request is aborting these requests as I type | |
more letters. So, when I backspace my request, ajaxCache finds the search | |
queries in its cache, but actually these queries were aborted. It thinks it has | |
the data, but it doesn't since it was aborted, so it returns nothing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment