Skip to content
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

rustdoc: use focus for search navigation #84462

Merged
merged 1 commit into from
May 18, 2021

Commits on May 13, 2021

  1. rustdoc: use focus for search navigation

    Rather than keeping track of highlighted element inside the JS, take
    advantage of `.focus()` and the :focus CSS pseudo-class.
    
    This required wrapping each row of results in one big <a> tag (because
    anchors can be focused, but table rows cannot). That in turn required
    moving from a table layout to a div layout with float.
    
    This makes it so Ctrl+Enter opens links in new tabs, and using the arrow
    keys to navigate off the bottom of the page scrolls the rest of the page
    into view. It also simplifies the keyboard event handling. It eliminates
    the need for click handlers on the search results, and for tracking
    mouse movements.
    
    This changes the UI treatment of mouse hovering. A hovered element now
    gets a light grey background, but does not change the focused element.
    It's possible to have two highlighted search results: one that is
    focused (via keyboard) and one that is hovered (via mouse). Pressing
    enter will activate the focused link; clicking will activate the hovered
    link. This matches up with how Firefox and Chrome handle suggestions in
    their URL bar, and avoids stray mouse movements changing the focus.
    
    Selecting tabs is now done with left/right arrows while any search
    result is focused. The visibility of results on each search tab is
    controlled with the "active" class, rather than by setting display: none
    directly. Note that the old code kept track of highlighted search
    element when tabbing back and forth. The new code doesn't.
    jsha committed May 13, 2021
    Configuration menu
    Copy the full SHA
    b615c0c View commit details
    Browse the repository at this point in the history