A place to hold tasks/notes about the TypeaheadSearch Codex component for WMDE.
(For the Wikipedia version of TypeaheadSearch, see T300081)
---
### Summary
The Design Systems Team is building a new version of TypeaheadSearch in Codex. Our first goal will be to meet the current use case covered by the WVUITypeaheadSearch component, and get the Codex version working in Vector on Wikipedias.
Our next goal will be to modify the CdxTypeaheadSearch component to work on wikidata.org, and to ensure that the implementation of CdxTypeaheadSearch in Vector has flexible configuration so different wikis can pass in a custom search client and other config variables.
### Feature specification
The following features are specific to the Wikidata use case and will need to be implemented:
#### Show more than 10 results
The current Vector implementation limits results to 10. To enable the display of more than 10 results, we need to do the following:
1. Make the results limit configurable in Vector **(needs subtask)**
2. Enable scrolling through results in CdxTypeaheadSearch (will be completed as part of T300565)
#### Custom search client (needs subtask)
These features relate to a custom search client, which will be passed into the skin that implements TypeaheadSearch via config vars, and which will fetch results and process them into data that CdxTypeaheadSearch can understand.
1. **Search includes entity IDs, plus labels and aliases in any language.** The current implementation of the search box in the legacy Vector skin on Wikidata uses the `action=wbsearchentities` API endpoint. On Wikidata, TypeaheadSearch must be able to hit this endpoint as well. In addition, the current implementation of TypeaheadSearch only searches page titles. On Wikidata, this equates to searching entity IDs, which is not usually helpful (but should still work: if I search for “Q42” then the matching entity should be shown in the results). In addition to page titles (i.e. entity IDs), labels and aliases should be searched, in any language.
2. **Matches outside the current language are fetched and displayed.** Since Wikidata search looks at labels and aliases in all languages, it might display results in a language other than the current one.
3. **Matching aliases of suggestions can be displayed.** The current implementation of TypeaheadSuggestion displays the page title and page description. On Wikidata, it should display the label, any matching aliases, and the description.
4. **Suggestions properly link to their Wikidata page.** This comment identifies an issue we will need to account for: the current URL generator for suggestions will need to be altered for Wikidata to link to the actual page of the suggestion.
5. **Test custom search client in Vector.** We need to enable passing in the custom client and test the Wikidata case.
Note: there is a [[ https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/759345/11/resources/skins.vector.search/restSearchClient.js | default search client ]] in Vector that will use a [[ https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/758961/7/resources/skins.vector.search/urlGenerator.js | default URL Generator ]]. We may not actually need to pass in a custom URL generator for Wikidata since it'll only be used to generate the search footer link (the link to the search page for the current search query). This depends on whether that link is the same for Wikipedia and Wikidata.
#### Language support
Additionally, we will need to make some changes to provide sufficient language support:
1. **Display results in the proper language(s).** Since results can be in a different language than the interface language, or could contain mixed languages (e.g. a label in one language and an alias in another), we need to be able to set a `lang` attribute on each part of the menu item (label, alias, and description). **(needs subtask)**
2. **Get sufficient language information back from the API.** In order to enable such granular language settings, we need to actually know the languages (and directions) of each part of the menu item text. This is not currently supported; see T104344