You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Focusing search results when directly navigating to rustdoc search #86882
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.
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[/+]on Jul 5, 2021
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.
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.
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.
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?
Activity
[-]Feature Request: Focusing search results when directly navigating to docs.rs search[/-][+]Feature Request: Focusing search results when directly navigating to rustdoc search[/+]Nemo157 commentedon Jul 5, 2021
The search page is actually part of rustdoc, docs.rs just hosts it for non-
stdcrates, so I've transferred the issue over.insou22 commentedon Jul 6, 2021
Oh I didn't realise -- thanks for that!
GuillaumeGomez commentedon Jul 10, 2021
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 commentedon Jul 10, 2021
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 commentedon Jul 10, 2021
@Manishearth You mean like this: #85876 ? ;)
Manishearth commentedon Jul 11, 2021
Oh we landed that cool!
insou22 commentedon 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 commentedon Jul 12, 2021
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 commentedon 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 commentedon Jul 12, 2021
No, if a search result is focused, up/down would go through the search results, not scroll the page. However, the spacebar would scroll.