Page MenuHomePhabricator

Feedback while searching
Closed, ResolvedPublic

Description

​Currently while typing an article title there is no feedback that confirms whether you are in the right track. There are two common ways to support that: (a) show an auto-complete panel as you type, or (b) update the main results as the user types. Supporting (a) is something the tool should offer.

Event Timeline

leila triaged this task as Medium priority.May 10 2016, 3:53 PM
leila moved this task from Backlog to Next Up on the GapFinder board.

Is the Wikipedia search suggestion box available as widget/extension/lib to integrate? Do we have to build one of our own?

Is the Wikipedia search suggestion box available as widget/extension/lib to integrate? Do we have to build one of our own?

I think @Jdrewniak integrated similar functionality in https://www.wikipedia.org/. He may know.

the search suggestions box on https://www.wikipedia.org isn't built as a widget/extension, but it can be easily integrated onto other pages since it's just a simple self-contained script and has nearly no dependancies (I can provide some guidance on that if desired).

There is also the mw.widgets.TitleWidget.js widget which can be used for this purpose too, but I'm not aware of the specifics of that implementation. There has been talk of using it for similar a effect on T125725

Sabya moved this task from Next Up to in-progress on the GapFinder board.

@Jdrewniak Thanks. Let's go with the first one. An example of it being used would be very helpful.

@Jdrewniak there are dependencies to addEvent, mw, getDevicePixelRatio. Could you pls point me to the right sources for getting these?

Hi @Sabya, sure
getDevicePixelRation is a simple polyfill to support hi-res thumbnails. It's located here:
https://github.com/wikimedia/portals/blob/master/dev/wikipedia.org/assets/js/polyfills.js#L306

addEvent is a polyfill for addEventListener, it should be removed since we dropped support for IE8, but here it is:
https://github.com/wikimedia/portals/blob/master/dev/wikipedia.org/assets/js/polyfills.js#L204
It requires a global window.attachedEvents array to work, as well as the removeEvent function.

mw contains the few helper functions we extracted from mediawiki core. Mostly for sanitizing content and generating html elements. This file is located here:
https://github.com/wikimedia/portals/blob/master/dev/wikipedia.org/assets/js/mediawiki.lite.js

Also, the CSS related to the typeahead is located here:
https://github.com/wikimedia/portals/blob/master/dev/wikipedia.org/assets/postcss/_wm-typeahead.css

Questions: what will be the behavior when I click on a search suggestion? Should it do anything other than filling up the search text input with the title of the suggestion?

@Sabya doing what you said plus searching. So once the user clicks on the suggestion, the search on the chosen selection should take place. This behavior is similar to what the user experiences if they search on en.wikipedia.org.

Here is a first working copy:

https://github.com/wikimedia-research/translation-recs-app/pull/55

I have few pending things pending, but you can try it out.

@schana: pls look into the PR and share your thoughts there