Skip to content

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

Open

Description

@insou22

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!

Activity

  1. transferred this issue fromrust-lang/docs.rson Jul 5, 2021
  2. 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
  3. Nemo157 commented on Jul 5, 2021

    @Nemo157
    Contributor

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

  4. insou22 commented on Jul 6, 2021

    @insou22
    Author

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

  5. GuillaumeGomez commented on Jul 10, 2021

    @GuillaumeGomez
    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 ?

  6. Manishearth commented on Jul 10, 2021

    @Manishearth
    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.

  7. GuillaumeGomez commented on Jul 10, 2021

    @GuillaumeGomez
    Member

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

  8. Manishearth commented on Jul 11, 2021

    @Manishearth
    Member

    Oh we landed that cool!

  9. insou22 commented on Jul 12, 2021

    @insou22
    Author

    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?

  10. GuillaumeGomez commented on Jul 12, 2021

    @GuillaumeGomez
    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.

  11. insou22 commented on Jul 12, 2021

    @insou22
    Author

    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?

  12. GuillaumeGomez commented on Jul 12, 2021

    @GuillaumeGomez
    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.

  13. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.
    on Jul 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-searchArea: Rustdoc's search featureC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions