Page MenuHomePhabricator

Have search suggest results open in a new tab on middle click
Closed, ResolvedPublic

Description

The search suggest feature is by far the most comfortable search method in MediaWiki, unfortunately there is no way to browse the suggestion list beyond clicking on the first, waiting for the page to load, typing the word in again (or pressing back and waiting for the old page to load) etc. It would be even more comfortable if middle click (or ctrl-click or whatever combination that specific browser uses) would open the page in a new tab.


Version: unspecified
Severity: enhancement

Details

Reference
bz17808

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:34 PM
bzimport set Reference to bz17808.

herd wrote:

There is no such thing as "open in new tab" that could be done server side (there are some CSS3 draft specs, but nothing useable).

The only thing that could be done automatically is to "open in new window", which /some/ browsers can send to a new tab, but not all.

One possible solution, though, would be to have the search suggest create <a> anchors linking to the results of the search for that word, that would allow the browser context menu on right click, which often includes 'open in new tab'.

(In reply to comment #1)
That would be my take too: change the <span>s to <a>s, and pass on the click event when it's not a left click.

(In reply to comment #2)
You can also check the event object for pressed modifier keys, though I'm not sure how cross-browser that is.

rainman wrote:

Makes sense, just need to make sure the links point to exactly the same url as form submit.

rd232 wrote:

*** Bug 28351 has been marked as a duplicate of this bug. ***

nzmoihue wrote:

Suggestion Dropdown

"It would be even more comfortable if middle click (or ctrl-click or whatever combination that specific browser uses) would open the page in a new tab.", I very like this idea.

I think this could be done with wrapping every item with <a> tag as you can see on my attachment.

attachment wikipedialink.html ignored as obsolete

nzmoihue wrote:

Suggestion Dropdown

Attached:

Just wrapping them in <a> doesn't work (if so, that would've been done in the first place). The primary use case is selecting an item from the list and submitting the search form.

If they are wrapped in a link, then clicking would go to that article instead of submitting the form. Right not it wouldn't make much difference though, since the search system usually redirects to the first result anyway.

Either way, the click handler would preventDefault() and submit the form, whilst still allowing non-default clicks (such as middle-click or context-menu > Open in new Tab)

The original poster wrote: "It would be even more comfortable if middle click (or ctrl-click or whatever combination that specific browser uses) would open the page in a new tab.

If you are interested, there is a JavaScript import to open search in a new tab
via Ctrl-click (PC) and Command-click (Mac). The Command key is the Apple key
on Apple keyboards. See:
http://commons.wikimedia.org/wiki/User_talk:Timeshifter/Open_search_in_new_tab.js

A related feature request is bug 35974. Preference or default setting to open
search result lists and suggestions in new tab.

nzmoihue wrote:

@Krinkle: I think it is possible to delete that JS modifications and let viewer select what they want to do with results. If viewer want to open search result on the same tab, they click on that result and if they want to see that result on new tab, they middle-click or ctrl+click on that result. Please let me know if this is not possible.

nzmoihue wrote:

@Krinkle: "Just wrapping them in <a> doesn't work (if so, that would've been done in the first place)." they didn't do that because they used /resource/query/jquery.suggestion.js for making suggestion menu.
Fixing Bug 35974 is easy by using this trick: http://css-tricks.com/snippets/html/form-submission-new-window/ but this is not a right way I guess.

But for fixing this bug I have a question, can I propose a modification on https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blob;f=resources/jquery/jquery.suggestions.js ? And can I don't use form.submit() on my solution?

Change I87940ca8 (linked in previous comment) merged.