Last modified: 2014-11-18 18:07:24 UTC
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.
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.
Makes sense, just need to make sure the links point to exactly the same url as form submit.
*** Bug 28351 has been marked as a duplicate of this bug. ***
Created attachment 10933 [details] 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.
Created attachment 10934 [details] Suggestion Dropdown
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.
@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.
@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?
In gerrit: https://gerrit.wikimedia.org/r/#/c/23674/ (based on patch by Ebrahim Byagowi).
Change I87940ca8 (linked in previous comment) merged.