Page MenuHomePhabricator

Typeahead suggestions sometimes freeze on results for incomplete search query
Closed, ResolvedPublic5 Estimated Story Points

Description

Due to how the requests are managed in wm-typeahead.js, results often arrive out of order. When that happens, the last one to arrive is also the last one to be applied to the user interface.

As such, I quite frequently experience that the shown results are for outdated query.

E.g. when typing "Amsterdam" I often get results for "Ams" and then it stays that way.

The current implementation does dereference JSONP script elements, but this does not cancel or abort the request. Even if cancelation was possible in browsers for script tags (which isn't possible), I'm not recommending that. Cancelling the previous request on each key stroke would mean that on slow connections no results show up until the user lets go of the keyboard for long enough.

Instead, the response handler should make sure to never apply updates for a response older than the last received response.

This way, when the user types "A", "Ams", "Amsterdam" and results arrive as "Ams", "Amsterdam", "A" the user sees results for "Ams" and then "Amsterdam". The response for "A" must be ignored.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

17:49 <Krinkle> jgirault: Note that "[", "]", 0-9 and _ are allowed
17:49 <Krinkle> so e.g. callbacks[1] would work
17:50 <Krinkle> or callback_1
17:50 <jgirault> Krinkle: interesting!
17:50 <Krinkle> Makes it easier to keep a map internally
17:51 <Krinkle> You'd presumably have a list of queries sent out, and whenever there is a response you drop anything from before that
17:51 <Krinkle> and if a response if for something you didn't ask for (or no longer in the 'needed' list) then you can ignore it

debt triaged this task as High priority.Mar 11 2016, 3:34 AM
debt moved this task from Backlog to To Discuss on the Discovery-Portal-Sprint board.
debt moved this task from To Discuss to What's Next on the Discovery-Portal-Sprint board.
debt added a subscriber: Jdrewniak.
Jdrewniak moved this task from What's Next to In Progress on the Discovery-Portal-Sprint board.
Jdrewniak set the point value for this task to 5.

Change 281983 had a related patch set uploaded (by Jdrewniak):
Guaranteeing the order in which search suggestions appear.

https://gerrit.wikimedia.org/r/281983

I approved the patch, but there are plenty of interesting comments in the gerrit patch regarding the implementation of this (the user experience, the performance...).

The debate was quite active and interesting. Though we didn't go with my approach, I think I brought up various points that are still worth considering.

Change 281983 merged by jenkins-bot:
Guaranteeing the order in which search suggestions appear.

https://gerrit.wikimedia.org/r/281983

looks good - tested on http://www.wikipedia.beta.wmflabs.org, it'll be part of this production release: https://phabricator.wikimedia.org/T130755