Lucas_Werkmeister_WMDE created this task.
Lucas_Werkmeister_WMDE added projects: Wikidata, wmde-wikidata-tech, Wikidata 
Dev Team, MediaWiki-Interface (autocomplete search).

TASK DESCRIPTION
  As a user or editor browsing the Wikidata website, I want to quickly navigate 
to search results when using the main search bar on the page.
  
  **Problem:**
  Currently, navigation for search results in the new Vector search works in 
two different ways.
  
  - If you interact with a search result as a link (left-click, middle-click, 
right-click + open in new tab, etc.), it sends you to the link address. With 
the default Vector URL generator, that link address is a Special:Search URL.
    - Example URL: 
https://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=Test
  - If you highlight a search result using the arrow keys on the keyboard, and 
then press Enter, then the behavior is the same as if you had entered the 
result’s label by hand and pressed Enter afterwards: you are sent to 
Special:Search with the result’s label as the search text, plus a hidden input 
for a wprov parameter <https://wikitech.wikimedia.org/wiki/Provenance>.
    - Example URL: 
https://en.wikipedia.org/w/index.php?search=Test&title=Special%3ASearch&wprov=acrw10
  
  In both cases, Special:Search will then redirect you to the page whose title 
exactly matches the search text (e.g. https://en.wikipedia.org/wiki/Test), 
unless it’s configured to show search results even for exact matches (either by 
user preference or, such as on Commons, even by default: 
https://commons.wikimedia.org/w/?search=Leonardo+da+Vinci does not redirect to 
https://commons.wikimedia.org/wiki/Leonardo_da_Vinci).
  
  The second approach doesn’t work at all for Wikidata items, where the search 
result’s label is not the same as the page title, or even uniquely identifies 
the search result: there are plenty of items labelled “Berlin”, but if I 
highlight the search result for Berlin, Illinois 
<https://www.wikidata.org/wiki/Q2504681> and press Enter, I want to navigate to 
that particular item, not a search results page for “Berlin” in general.
  
  **Example:**
  Currently, you can only try this out using the proof of concept from T316093 
<https://phabricator.wikimedia.org/T316093>; you can paste the following code 
into the console on Test Wikidata 
<https://test.wikidata.org/wiki/Wikidata:Main_Page?useskin=vector-2022> (not 
real Wikidata):
  
    var vectorSearchClient = {
                        fetchByTitle: ( q, domain, limit = 10, showDescription 
= true ) => {
                                var api = new mw.Api();
                                var data = {
                                        action: 'wbsearchentities',
                                        search: q,
                                        format: 'json',
                                        errorformat: 'plaintext',
                                        language: 'en',
                                        uselang: 'en',
                                        type: 'item'
                                }
                                var getJson = api.get( data );
    
                                function getMatchText( { type, text } ) {
                                        if ( type === 'alias' || type === 
'entityId' ) {
                                                return text;
                                        }
    
                                        return '';
                                }
    
                                const searchResponsePromise = getJson.then( ( 
res ) => {
                                        return {
                                                query: q,
                                                results: res.search.map( ( { 
id, label, title, url, match, description, display = {} } ) => ( {
                                                        value: id,
                                                        label,
                                                        match: getMatchText( 
match ),
                                                        description,
                                                        title,
                                                        url,
                                                        language: {
                                                                label: 
display?.label?.language,
                                                                match: 
match.type === 'alias' ? match.language : undefined,
                                                                description: 
display?.description?.language
                                                        },
                                                } ) ),
                                        };
                                } );
    
                                return {
                                        fetch: searchResponsePromise,
                                        abort: () => {
                                                api.abort();
                                        }
                                };
                        }
                };
    
                mw.config.set( 'wgVectorSearchClient', vectorSearchClient );
  
  Otherwise, you can see the described behavior difference e.g. on English 
Wikipedia <https://en.wikipedia.org/wiki/Main_Page?useskin=vector-2022>, if you 
look at the network monitor – each way of selecting a search result will 
eventually send you to the result page, but the Special:Search URLs in between 
will look slightly different depending on whether you clicked a search result 
or selected it using the keyboard.
  
  **Screenshots/mockups:**
  
  **BDD**
  GIVEN I am on a wiki using the Vector 2022 skin
  AND Wikibase is configured to provide custom search results for Vector 2022’s 
search (instead of the default title-based search)
  WHEN I search for a string
  AND highlight a result using the arrow keys
  AND press Enter
  THEN I am redirected to the item I highlighted
  
  **Acceptance criteria:**
  
  - Users can select and navigate to search results using the keyboard on 
Wikidata
  
  **Open questions:**

TASK DETAIL
  https://phabricator.wikimedia.org/T317681

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Lucas_Werkmeister_WMDE
Cc: Michael, Aklapper, jhsoby, Lucas_Werkmeister_WMDE, Astuthiodit_1, 
karapayneWMDE, Invadibot, maantietaja, NavinRizwi, ItamarWMDE, Akuckartz, 
DannyS712, Nandana, Amorymeltzer, Lahi, Gq86, GoranSMilovanovic, QZanden, 
LawExplorer, _jensen, rosalieper, Scott_WUaS, Wikidata-bugs, aude, Dinoguy1000, 
Mbch331, Jay8g
_______________________________________________
Wikidata-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to