rust/src/librustdoc
Ralf Jung c9b6bb9279
Rollup merge of #84462 - jsha:focus-search-results2, r=GuillaumeGomez
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 focus. 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.

Demo at https://hoffman-andrews.com/rust/focus-search-results2/std/?search=fn

Fixes #84384
Fixes #79962
Fixes #79872
2021-05-18 19:35:35 +02:00
..
clean Auto merge of #85178 - cjgillot:local-crate, r=oli-obk 2021-05-17 01:42:03 +00:00
doctest Fix injected errors when running doctests on a crate named after a keyword 2021-02-11 17:16:43 -05:00
formats Minimize amount of fake DefIds used in rustdoc 2021-05-15 13:21:35 +02:00
html Rollup merge of #84462 - jsha:focus-search-results2, r=GuillaumeGomez 2021-05-18 19:35:35 +02:00
json Minimize amount of fake DefIds used in rustdoc 2021-05-15 13:21:35 +02:00
passes Fix rebase conflicts 2021-05-17 23:33:04 -04:00
theme Add test to check if minified theme are handled correctly 2020-02-12 15:49:39 +01:00
Cargo.toml Use arrayvec 0.7, drop smallvec 0.6 2021-04-21 22:39:08 -07:00
config.rs Only show type layout info if --show-type-layout is passed 2021-05-11 09:55:31 -07:00
core.rs Auto merge of #85178 - cjgillot:local-crate, r=oli-obk 2021-05-17 01:42:03 +00:00
docfs.rs Make all rustdoc functions and structs crate-private 2020-11-15 11:21:12 -05:00
doctest.rs Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
doctree.rs compute where_outer on demand, remove it from Module 2021-05-01 15:33:49 +02:00
error.rs Make all rustdoc functions and structs crate-private 2020-11-15 11:21:12 -05:00
externalfiles.rs Make all rustdoc functions and structs crate-private 2020-11-15 11:21:12 -05:00
fold.rs rustdoc: Remove unnecessary StripItem wrapper 2021-05-04 21:56:27 -04:00
lib.rs Only show type layout info if --show-type-layout is passed 2021-05-11 09:55:31 -07:00
lint.rs Rename INVALID_RUST_CODEBLOCK{,S} 2021-05-17 21:31:04 -04:00
markdown.rs Make all rustdoc functions and structs crate-private 2020-11-15 11:21:12 -05:00
README.md rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.org 2020-03-10 17:08:18 -03:00
theme.rs Change librustdoc write(.. \n) to writeln(..); fix comment in grammar 2021-05-03 02:19:57 -05:00
visit_ast.rs Add type to differentiate between fake and real DefId's 2021-05-04 19:34:12 +02:00
visit_lib.rs Remove the dummy cache in DocContext 2021-03-01 00:30:30 -05:00

For more information about how librustdoc works, see the rustc dev guide.