Page MenuHomePhabricator

[Bug] Control clicking search result doesn't open in new tab
Closed, DuplicatePublic5 Estimated Story Points

Description

Precusor

  • T189173 should be resolved before tackling this one.

Steps to Reproduce

  1. https://en.m.wikipedia.org/
  2. Click the search box at the top of the page
  3. Search for "a"
  4. Control-click the first result

Screen Shot 2018-10-08 at 1.47.09 PM.png (267×445 px, 48 KB)

Expected Results

  • Result opens in new tab just as it does for middle-clicking

Actual Results

  • Result opens in current tab and destroys browsing context

Environments Observed

  • Production enwiki on Minerva

Browser Version

  • Chromium 69.0.3497.81

OS Version

  • Ubuntu v18.04

Device Model

  • Desktop

Device Language

  • English

Developer notes

Problem 1: The link only wraps the text.

Screen Shot 2018-10-08 at 1.47.34 PM.png (101×440 px, 18 KB)

Since cards are fixed width and height, the link could be made position absolute to contain the whole card.

I recommend making use of the same HTML/CSS that RelatedArticles uses:

Screen Shot 2018-10-08 at 1.50.11 PM.png (183×1 px, 32 KB)

Note: The WatchstarPageList component is widely.
To migitate risk of breaking other consumers, it might make sense to use this opportunity to create a Card component and simplifies the logic in resources/mobile.search/SearchOverlay.js and removes its dependency on WatchstarPageList

It might however make sense to fix this everywhere. Choose your own adventure!

Problem 2: Behaviour

A bigger problem is the SearchOverlay.prototype.onClickResult handles the clicking and uses JS to make sure the search overlay is closed prior to navigating to a link.

This seems to be written to clear the hash and is self-described as an "ugly hack".

How to ensure the hash fragment is cleared before leaving the page?
A better way to do this would be to use replaceState but not preventDefault.
Looks like T189173 needs to be done first

                onClickResult: function ( ev ) {
...

                        // FIXME: ugly hack that removes search from browser history
                        // when navigating to search results
                        ev.preventDefault();
                        this.router.back().then( function () {
                                // Router.navigate does not support changing href.
                                // FIXME: Needs upstream change T189173
                                // eslint-disable-next-line no-restricted-properties
                                window.location.href = $link.attr( 'href' );
                        } );
                },

becomes

onClickResult: function ( ev ) {
        router.navigate( { path: '#', useReplaceState: true } );
},

Note:
There is a related issue to this hack that I've seen and assume is because of the back button click. Sometimes when clicking on a search result on mobile, the search overlay closes and I do not see the page I just clicked on. I assume this is because the back button is async and happening after the navigation to the page in question.

Patch of proposed fix with imagined API:

Event Timeline

Restricted Application changed the subtype of this task from "Deadline" to "Task". · View Herald TranscriptOct 5 2018, 5:42 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Jdlrobson updated the task description. (Show Details)
Jdlrobson updated the task description. (Show Details)
ovasileva set the point value for this task to 5.Oct 10 2018, 4:48 PM
Jdlrobson lowered the priority of this task from Medium to Low.Jul 31 2019, 6:53 PM
Jdlrobson raised the priority of this task from Low to Medium.Sep 10 2019, 2:22 PM
ovasileva lowered the priority of this task from Medium to Low.Oct 22 2020, 3:35 PM