Skip to content

Middle-clicking on search results should not load the link on the same page #16754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

Manishearth
Copy link
Member

Middle clicking is usually used for opening a link in a new tab in most browsers. It's an easy way to navigate without losing your current page.

When using rustdoc's search, I'd like to be able to middle-click on search results so that I can open multiple results in new tabs. However, currently the onclick listener captures middle clicks too, so link opens in two places — in a new tab, and on the same page.

This partially fixes it. It would be better if the anchor tag on a result spanned the entire result path+name, and not just the name -- while normal clicking still works due to the event handler, middle clicking is broken if you click on something other than the result name (not the path). I don't mind doing it that way, but it seems like there was a reason behind having the a tag only cover the name. (Code pointer in case I need it in the future)

@Gankra
Copy link
Contributor

Gankra commented Aug 25, 2014

This code is certainly correct as far as I can tell. Unsure if we want to explore anything in your discussion of the issue, though.

Regardless, fixes #16320

@steveklabnik
Copy link
Member

Middle clicking already works for me, on Ubuntu/Firefox, so I hope this doesn't break it...

@Manishearth
Copy link
Member Author

I pushed an improved fix that expands middle-clicking to the entire search result.

Firefox on Ubuntu isn't broken because of this, but the added benefit of being able to middle click anywhere on the full path is not gained. Apparently Chrome considers onclick to include middle click, but Firefox doesn't.

Let me know which one we want, or if we want it.

@ftxqxd
Copy link
Contributor

ftxqxd commented Aug 26, 2014

I occasionally control-click to open a link in a new tab. Middle-clicking the link works just fine right now for me, and middle-clicking the entire result does nothing. Control-clicking the link opens a new tab and loads the selected result in the same tab, and control-clicking the entire result just opens it in the same tab. Does/could this fix this as well?

@huonw
Copy link
Member

huonw commented Aug 26, 2014

Is there a reason we can't make each result a proper <a> with a proper href="..." (meaning all link-related browser functionality works out of the box)?

@Manishearth
Copy link
Member Author

@P1start This won't fix ctrl-clicking, but it can with ease.

@huonw That's what I'm thinking of doing now, though it requires some CSS changes which I don't have the tiem to do today. A nested <a> tag is the quickest way of getting it done.

@huonw
Copy link
Member

huonw commented Sep 4, 2014

cc #16909

@Manishearth Manishearth closed this Sep 5, 2014
@Manishearth Manishearth deleted the middle-click branch January 10, 2015 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants