Page MenuHomePhabricator

Search submit button and SearchSuggest should support native "open link in new tab" functionality
Closed, ResolvedPublic

Description

I propose a preference for opening search results and suggestions in new tabs. I suggest basing it on the JavaScript found here:
*http://commons.wikimedia.org/wiki/MediaWiki:Search-results-new-tab.js

I have tested it on both Wikipedia and the Commons. It works great. For more info read the talk page here:
http://commons.wikimedia.org/wiki/MediaWiki_talk:Search-results-new-tab.js

I am an admin on a Wikia wiki too, and would like this to be a preference on that MediaWiki installation too. That is why I am requesting here for it to be a preference on all MediaWiki installations.

There are similar bug requests on Bugzilla, but they are not what I want. I want all search clicks to open a new tab. I do not want to have to middle click, or shift-enter, or right click. Plus I do not want to have to deal with browser differences. I just want

target: '_blank'

added by the preference.


Version: unspecified
Severity: enhancement

Details

Reference
bz35974

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 12:19 AM
bzimport set Reference to bz35974.

wikimedia wrote:

An Gadget for that should be satisfactory in my opinion.

For the record: on Google Chrome 18.0.1025.162, that gadget prevents the use of ALT+SHIFT+TAB right after hiting ENTER in the search field.
See: [[commons:MediaWiki_talk:Search-results-new-tab.js#Bug]].

This do not happens on Firefox 11.0

Is there any reason this can not be the default setting for MediaWiki installations?

(In reply to comment #3)

Is there any reason this can not be the default setting for MediaWiki
installations?

Preferences become overwhelming. A gadget would be the right way to go. Since this is something you want, you could even set up a global gadget on Meta for yourself.

I agree that there are a lot of preferences. But this is a fairly basic preference. Search is the number one thing many people want on a site. And if it were the default setting, then it would not be a preference. Most readers and editors do not change the default preference and gadget settings much. And going to a global gadget setting on Meta is beyond the knowledge of most casual readers and editors.

Most readers do not know much about how to find stuff on the commons and Wikipedia. They try the search form, but soon see that it covers up the page they are looking at. Many people stop using the search form after that, and use Google toolbar instead. I did that for a long time. But Google toolbar does not have a separate category search as does the Commons search form that shows up after the initial search. Google toolbar does not allow one to pick and choose namespaces to search as does the search form that shows up after the initial search.

There are a couple ways to fix this.

  1. Put an advanced search link in the sidebar. It would link to Special:Search.
  1. Make search suggestions and results show up in a new tab by default.

saibotrash wrote:

The enforcement of link opening in new windows / tabs is quite a bad idea. You are stripping of the choice of the user to open in a new tab or not. Don't do that. If you like it, enable this gadget for you - but don't default to that. It is annoying if websites try to alter the browser's default behaviour (that was in the late 90s... we are in 2012 now!).

I can live with either option being the default. But right now the user does not have a choice. The user can only open in the same tab. A preference gives logged-in users a choice. In addition, putting a search link in the sidebar gives all users a choice (both logged-in and non-logged-in users). So I think there should be a preference, and a search link in the sidebar. Many registered users do not change their preferences much, if at all. So a sidebar link helps the most users.

(In reply to comment #7)

Many registered
users do not change their preferences much, if at all. So a sidebar link helps
the most users.

That's the precise argument against adding a preference. If almost nobody changes it--sane universal behavior is preferred.

I agree with everyone above who said this should be a gadget instead -> being bold and marking this WONTFIX.

Most people prefer opening search results in new tabs when given a choice. So it is not logical to mark this as WONTFIX. More and more Firefox search addons also offer a choice of opening search results in new tabs. When you go to Google do you go to a new tab to search, or do you search in the same tab, and cover the page that caused you to want to do the search? Is it logical or sane to cover up the page you want more info about?

(In reply to comment #9)

Most people prefer opening search results in new tabs when given a choice.

"Most people..." statements are nearly always subjective. Numbers welcome.

Most browsers allow users to use Ctrl+click or middle-click to explicitly state that they want to open something in a new tab.
I consider opening a new tab without asking me rather unfriendly (paternalism?).
If this was default, one would either have to find out where to change that setting, or (as one can be rather lazy) one would have to close the old tab manually every time when the search results pop up.

While there certainly is an amount of users that prefer to get a new tab it is unclear how big this group is, and how big the group is that doesn't prefer it.

Hence proposing WONTFIX for the time being as there is no strong indicator (yet) that this change would be useful for the majority.

The Ctrl+click or middle-click option in browsers is problematic in many cases from my reading. I believe that is one reason why more and more Firefox search addons are providing the option to open results in a new tab.

This preference would probably be used a lot more than many of the other preferences. That is why it should not be WONTFIX.

I can see your point about "opening a new tab without asking me rather unfriendly" for some people. So I guess this should be a preference and not the default setting.

(In reply to comment #11)

This preference would probably be used a lot more than many of the other
preferences.

That should be proved or disproved by adding this as a gadget and then someone could provide an update of [[Wikipedia talk:Gadget#Usage-Stats]] (or [[Wikipedia:Database_reports/User_preferences#Gadgets]]) to see if it is worth to move this to a preference instead of letting as a gadget.

I think it is proved by the fact that more and more Firefox search addons provide the option to open results in new tabs.

saibotrash wrote:

(In reply to comment #7)

But right now the user does not have a choice. The user can only open in the same tab.

Ah, I misunderstood your request. I thought you mean the links to the file pages on the result page - but you seem to mean the result page should be a new tab. Very unexpected for such an search input field. Also it would force the user to close tabs again and again although he knows that he want to navigate away from the current page. I do not see the need here. There may be special use cases where someone would use the search box over and over but wants to keep the current page each time - but that does not justify to overrule all users. I see no need for a MediaWiki solution. That can be done by Gadgets if needed (even opt-out is possible).

That is why I now agree that it should be a preference and not a default setting. People who have used this tend to like it. The creator of the JavaScript for Wikipedia and the Commons (after I suggested it) found it quite handy. As do the people on Wikia who have used it.

I found a better method to open search in a new tab. See:
*http://en.wikipedia.org/wiki/Wikipedia:Gadget/proposals#Ctrl-click_to_open_search_in_new_tab

Add the following revised JS to Special:MyPage/common.js

/* Ctrl-click to open search buttons in new tab */

$('#searchform, #search, #powersearch, #searchbox, .search-types, #search-types').bind('keyup keydown mousedown',

function (e){ $(this).attr('target', e.ctrlKey?'_blank':'') })

Ctrl-click now works for opening both Wikipedia search buttons and Wikipedia search links in new tabs.
http://en.wikipedia.org/wiki/Special:Search

In Special:Search the search options initially found below the search form are in the form of links. The search form itself uses a submit button. As does the search form at the top right of every page. And the search forms for searching archives.

It sure would be nice if this was a preference in core MediaWiki software. Then all wikis everywhere would not have to keep reinventing the wheel in order to add a way to open search in a new tab.

Here is a JavaScript (JS) version below that works for both PCs (Ctrl-click) and Macs (via Cmd-click. Command/Apple key). It works in Firefox, Chrome, Internet Explorer, and Safari. It works for both search submit buttons, and search suggestions in the dropdown. It works on Wikipedia and the Commons. It is from here:
http://commons.wikimedia.org/wiki/Commons:Village_pump/Proposals#Revised_version_that_also_works_for_Mac_users

/* Ctrl-click (PC) and Cmd-click (Mac) to open search in new tab */

$('#searchform, #searchbox, #search, .search-types, #search-types, #powersearch').bind('keyup keydown mousedown',

function (e){ $(this).attr('target', e.ctrlKey||e.metaKey?'_blank':'') })

Add the above JS to here:
*http://commons.wikimedia.org/wiki/Special:MyPage/common.js
*http://en.wikipedia.org/wiki/Special:MyPage/common.js

Note: Here are the component parts and what they effect:

#searchform - embedded search form at top right of every page.
#searchbox - embedded archive search forms. For example;
http://commons.wikimedia.org/wiki/Template:Village_pump_archives
http://commons.wikimedia.org/wiki/Commons:Village_pump/Header
http://commons.wikimedia.org/wiki/Commons:Village_pump/Proposals/Header
#search, .search-types, #search-types - Special:Search.
#powersearch - advanced search at Special:Search. This is after one clicks the advanced search link at Special:Search to get the dropdown of search choices. Then when one clicks the search button, #powersearch applies to it. Special:Search links:
*http://en.wikipedia.org/wiki/Special:Search
*http://commons.wikimedia.org/wiki/Special:Search

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

It makes search result lists or suggestions open in a new tab (if the browser supports it). I am using it on Wikipedia, the Commons, and MediaWiki.org so far. Without problems. I suggest that it be made a preference in the search tab of my preferences:
*http://en.wikipedia.org/wiki/Special:Preferences#mw-prefsection-searchoptions

Here is the description and the JS import code:

/* Ctrl-click (PC) and Command-click (Mac) to open search in new tab */
/* The Command key is the Apple key on Apple keyboards */
/* commons.wikimedia.org/wiki/User_talk:Timeshifter/Open_search_in_new_tab.js */

mw.loader.load('//commons.wikimedia.org/w/index.php?title=User:Timeshifter/Open_search_in_new_tab.js&action=raw&ctype=text/javascript');

Copy it to here:
*http://en.wikipedia.org/wiki/Special:MyPage/common.js
*http://commons.wikimedia.org/wiki/Special:MyPage/common.js
*http://www.mediawiki.org/wiki/Special:MyPage/common.js
*or other-language Wikipedias, or other Wikimedia projects.

Example:
*http://en.wikipedia.org/wiki/User:Timeshifter/common.js

People are unhappy that they can not open search in a new tab. For example; see bug 34756.

On the Commons this is now a gadget which can be enabled or disabled in your preferences. See:
*[[commons:Special:Preferences#mw-prefsection-gadgets]] - in the section called "Interface: Other". It is listed as:

"Search results in new tab : Make the search result (list) open in a new tab by pressing Ctrl (PC) or ⌘ Command (Mac) while submitting."

For more info see:
*[[commons:MediaWiki talk:Gadget-search-new-tab.js]]

Other discussions are linked from that page. Also, the functionality can be imported to your personal common.js page on any Wikimedia Project. See that page.

Timeshifter, a patch to another bug(s) (bug 21167, bug 17808) fixed part of the issue (the dropdown links not being links): I87940ca8.

I am going to make the form submits actual form submits, which should allow for this out-of-the-box, the way it works for regular forms, but I want that one merged first.

I'm wontfixing this per previous comments. The issue of search form not respecting [Shift/Ctrl]+Enter is now bug 44393.

I reopened it. I think you misunderstand part of this thread. It is mainly about the lists themselves opening up in a new tab.

I will remove "suggestions" from the title of this thread.

Both Wikipedia and the Commons now have a gadget in preferences for opening search result lists in new tabs via Ctrl-click. It would be even better if this were a preference in all MediaWiki installations. Here are the gadgets:

Using long URLs too because the pound character (#) may not work in Mediawiki-style bracketed links on Bugzilla. See: [[WP:Bugzilla]].

English Wikipedia:
*http://en.wikipedia.org/wiki/Special:Preferences#mw-prefsection-gadgets
*[[Special:Preferences#mw-prefsection-gadgets]] - "Open search results in new tab/window when holding down the CTRL-key" in the browsing section.

Commons:
*http://commons.wikimedia.org/wiki/Special:Preferences#mw-prefsection-gadgets
*[[commons:Special:Preferences#mw-prefsection-gadgets]] - "Search results in new tab: Make the search result (list) open in a new tab by pressing Ctrl (PC) or ⌘ Command (Mac) while submitting" in the "Interface: Other" section.
*[[*commons:MediaWiki talk:Gadget-search-new-tab.js]]

Oops. Messed up one of the links. Why is there no preview on Bugzilla after all these years??? Here are the links to the JS pages:
*[[commons:MediaWiki:Gadget-search-new-tab.js]]
*[[commons:MediaWiki talk:Gadget-search-new-tab.js]]
*[[MediaWiki:Gadget-search-new-tab.js]]

How is this not bug 44393?

These gadgets simply open search results (or the article you clicked in the suggestion list) in new tab when Ctrl is pressed. This is precisely what I'm suggesting, except that some browsers (e.g. Opera) natively use Shift instead of Ctrl to open results of form submission in a new tab, so I'd like to support this. (This works on any form anywhere, in Opera at least.)

(In reply to comment #23)

Why is there no preview on Bugzilla after all these years???

Because there's no good reason to have one (all the [[wikimarkup]] link support is a custom hack of Wikimedia), and apart from that the same reason as for anything else missing: Because nobody has written such code yet. Patches are welcome in https://bugzilla.mozilla.org/show_bug.cgi?id=40896

(In reply to comment #24)

How is this not bug 44393?

Bartosz Dziewoński. I see what you are trying to do, I think. Let me suggest this. There is already Bug 17808 "Have search suggest results open in a new tab on middle click".

This bug thread (35974) we are in now is currently focused on this: "open search result lists in new tab via Ctrl-click".

So since I removed search suggestions from the title of this thread, there is no longer a need for Bug 44393. It is only one post so far anyway, and this thread here is where most discussion has occurred concerning search result lists in new tabs.

I get the impression that Gerrit change I87940ca8 effects only search suggestions and not search result lists.

The Firefox browser can not normally open form submit results in a new tab. Neither by Ctrl-click, Shift-click, or right click. Try the search form at the top of this page:
*http://www.bugzilla.org

With Firefox one has to install an addon such as TabSubmit:
*https://addons.mozilla.org/en-us/firefox/addon/tabsubmit - "Lets the user direct the submission of a form to a new tab or window."

Created attachment 11699
A drawing to go with comment 27.

Sorry, but I still don't see how is this different than what I'm proposing right now. Can you define "search suggestions" and "search result lists"?

I made a helpful graphic (in the attachment). The red part I'll call "the dropdown", the green "the input", and the light-blue "the button". I'll also use "Shift" to refer to any key that allows one to open something (a form result or a link) in a new tab for simplicity; adjust accordingly for whichever browser you use.

The situation is like this:

  • Right now, the version of MediaWiki deployed on WMF wikis doesn't support middle-clicking, Shift-clicking, nor any other way I know of to open neither search results, nor the specific article from the dropdown on a new tab/window.
  • With my patch for bug 21167 & bug 17808 (not yet deployed on WMF wikis, but it will be soon - see https://www.mediawiki.org/wiki/MediaWiki_1.21/Roadmap), the dropdown support Shift-clicking and middle-clicking naturally (since it is built on regular <a> links). However, you can't Shift-submit the form using either the input or the button, as the keypress is captured by JavaScript events.
  • It looks that the gadget you linked enabled Shift-clicking and Shift-submitting on everything by the virtue of enforcing form submission target to be a new tab if Shift is pressed, and this tab if it isn't. This, well, works, but personally I don't like this solution at all from the "purity" standpoint :)

What I'm going to work on is to allow the form submission to happen "naturally" as well. This would allow Shift-submission to work in browsers supporting it, and not do anything in the rest - I don't know about others, Opera certainly does. (That Firefox addon should probably work, too.)

I hope I made it all clear now from my side So once again - please define "search suggestions" and "search result lists", so that we both understand each other :)

Attached:

suggestions.PNG (364×526 px, 28 KB)

I see now that we are talking about 3 different things: search suggestions, and 2 kinds of form submission.

This thread (that I started) is concerned mainly with the submit button, and also the search result list that is returned when one clicks "containing Poland" at the bottom of the dropdown list. I am referring to the image you linked to.

Here is a page elsewhere with a search form at the top:
*http://www.bugzilla.org

I tested 3 browsers. Chrome allows one to Ctrl-click a form submit button (or "containing..." link, to open the results in a new tab, or to Shift-click to open the results in a new window.

Firefox and Internet Explorer do not allow one to submit a form to a new tab or window by ctrl-click, shift-click, middle click, right click, etc.

See Bugzilla@Mozilla - "Bug 17754 - Ability to submit form in a new window / tab (when button is middle or right clicked)":
*https://bugzilla.mozilla.org/show_bug.cgi?id=17754#c124

The Firefox developers are not going to add this ability. See comment 124 and 151 in that thread. Thanks are due to Andre Klapper and his comment in that thread pointing out those two authoritative comments, 124 and 151.

My suggestion is to allow one to choose this option by checking off a box in the search tab of my preferences:
[[Special:Preferences#mw-prefsection-searchoptions]]

This could be built in to MediaWiki as an option. Then people would not have to install the gadget in every MediaWiki installation it could be useful in.

(Sorry for late comment, I am quite busy recently.)

Thanks, this seems pretty clear now; I'll take the liberty of updating the bug summary.

Firefox not being able to do that, for some vague and IMO misguided design reasons, is a good point; but I'm personally really unsure if we should be implementing this for them. CC'ing Krinkle (Timo) and Anomie (Brad); can you share your opinion on this? :)

Now, if this is implemented, I don't think that it should be a preference; we have way too many of them already, and the few users who really need it can use a one-line JavaScript snippet. It's not even clear what would the pref do: if it would just allow for Shift-submission in the browsers that don't support it natively, then I see no reason not to enable it for everyone if it's implemented anyway; if it would force opening the results in new tab on every submit, this could quickly get annoying.

For now, I'll work on cleaning up the form submissions for the browsers that support it (per the bug 44393 I created earlier).

Waiting for Krinkle's and Anomie's input.

So it looks like this bug is about making Ctrl-clicking the submit button in the search form submit to a new tab. I see no point to making it a preference, if this is going to be done just do it. And IMO it should also do it for middle click on the submit button, if possible.

As for whether it *should* be done, I have no opinion.

This bug is about the "Open in new tab" functionality on the suggested page titles in the dropdown (which should ba <a> tags) via right-click "Open in new tab" or some shortcut that the browser may implement via some control key or third mouse button.

This bug (that I started) is also about ctrl/shift/right/middle clicking the search submit button, and getting the results list to show up in a new tab.

SearchSuggest is just for the drop-down list of suggestions, not the search submit button. See
*[[Search suggest drop-down list]].

In any browser you can already right-click a search suggestion from the drop-down list and open the suggested page in a new tab or window via the context menu.

But only Chrome and Opera allow one to ctrl-click a search suggestion to get the suggested page to open in a new tab.

Oops, my Opera info is wrong. I installed Opera today. My previous info on Opera was from my mistaken understanding of what others had written in this thread.

From my testing today, Opera, at least in its default settings, does not open English Wikipedia's search suggestions via ctrl-click or shift-click. Nor by right-clicking. The same is true for the search submit button.

On search forms outside English Wikipedia Opera does open the search results list in a new tab via ctrl-click or shift-click. Try the search form here:
*http://www.bugzilla.org

Opera opens a regular link in a new tab via ctrl-click or shift-click.

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

I submitted I49ef7cc8 to make this work on Opera and Chrome, but there are still some issues with the change. Please watch the changeset for updates on progress :)

(Also I killed that bug I split off earlier, that was a bad idea.)

Change 48252 had a related patch set uploaded by Matmarex:
jquery.suggestions, mediawiki.searchSuggest: Fix form submission

https://gerrit.wikimedia.org/r/48252

Change 48252 merged by jenkins-bot:
jquery.suggestions, mediawiki.searchSuggest: Fix form submission

https://gerrit.wikimedia.org/r/48252

This should work now (the fix is not deployed on Wikimedia wikis yet). Please report any problems that might seem related. :)