Skip to content

Feature Request: Focusing search results when directly navigating to rustdoc search #86882

New issue

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

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

Already on GitHub? # to your account

Open
insou22 opened this issue Jul 5, 2021 · 10 comments
Labels
A-rustdoc-search Area: Rustdoc's search feature C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@insou22
Copy link

insou22 commented Jul 5, 2021

When users type something like !rust Box into a search engine like DuckDuckGo, it will navigate you to the docs.rs std search like this: https://doc.rust-lang.org/std/?search=Box

The behavior I would like to see is that once I reach the search page, I can simply hit Enter to navigate to the first result: std::boxed::Box, or alternatively navigate between the different options just by immediately using the arrow keys -- i.e. not having to use the mouse. The current behavior is that I have to either click on the option I want with my mouse, or click into the search bar before I'm able to then use the arrow keys / Enter to get to my option.

Is it a possibility to make it so that when a search query page is directly navigated to, it can allow you to immediately interact with the search results via keyboard? Obviously we wouldn't want to steal input focus away from a user who is still typing their query in however, so that's an important distinction.

I'm also happy to have a go at implementing this feature myself, assuming this is something that people are happy to see integrated.

Cheers!

@Nemo157 Nemo157 transferred this issue from rust-lang/docs.rs Jul 5, 2021
@Nemo157 Nemo157 changed the title Feature Request: Focusing search results when directly navigating to docs.rs search Feature Request: Focusing search results when directly navigating to rustdoc search Jul 5, 2021
@Nemo157
Copy link
Member

Nemo157 commented Jul 5, 2021

The search page is actually part of rustdoc, docs.rs just hosts it for non-std crates, so I've transferred the issue over.

@Nemo157 Nemo157 added the A-rustdoc-search Area: Rustdoc's search feature label Jul 5, 2021
@insou22
Copy link
Author

insou22 commented Jul 6, 2021

Oh I didn't realise -- thanks for that!

@GuillaumeGomez
Copy link
Member

The focus on the search input was ruled out in #77333 because it prevented to scroll the page with the spacebar. However, in what you suggested, it wouldn't prevent it. I think we should go for it.

What do you think @rust-lang/rustdoc ?

@Manishearth
Copy link
Member

Yeah if it's directly navigated to it makes sense

Though actually what I want is a query parameter that will also navigate directly to the first result on your behalf so that I can set up my custom searches to use it.

@GuillaumeGomez
Copy link
Member

@Manishearth You mean like this: #85876 ? ;)

@Manishearth
Copy link
Member

Oh we landed that cool!

@insou22
Copy link
Author

insou22 commented Jul 12, 2021

Thanks for linking the related issues / PRs @GuillaumeGomez !

I'm wondering if this solution breaks that premise also, as although you can still use the spacebar to scroll the page, up/down won't scroll anymore.

Is this a reasonable compromise for both sides of things, or still just the same issue?

@GuillaumeGomez
Copy link
Member

Up/down would still work actually. We made a lot of changes recently on the search results, so now the event isn't only when you are focused on the search input but also when you are focused on a search result "row". So in this regard, it would be perfectly fine.

@insou22
Copy link
Author

insou22 commented Jul 12, 2021

Ah okay, so please correct me if I'm wrong here but as I understand it, we would only be making navigate to the first result, and up/down will still simply scroll the page rather than navigating through the search results?

@GuillaumeGomez
Copy link
Member

No, if a search result is focused, up/down would go through the search results, not scroll the page. However, the spacebar would scroll.

@camelid camelid added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Jul 17, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-rustdoc-search Area: Rustdoc's search feature C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants