Rollup merge of #123355 - mu001999:rustdoc/search, r=GuillaumeGomez

Support type '/' to search

Related topic on IRLO: https://internals.rust-lang.org/t/rustdoc-use-key-to-search-instead-of-s/20559
This commit is contained in:
Matthias Krüger 2024-04-16 17:54:40 +02:00 committed by GitHub
commit 49f6c95ba3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -462,6 +462,7 @@ function preLoadCss(cssUrl) {
case "s": case "s":
case "S": case "S":
case "/":
ev.preventDefault(); ev.preventDefault();
searchState.focus(); searchState.focus();
break; break;
@ -1334,7 +1335,7 @@ function preLoadCss(cssUrl) {
const shortcuts = [ const shortcuts = [
["?", "Show this help dialog"], ["?", "Show this help dialog"],
["S", "Focus the search field"], ["S / /", "Focus the search field"],
["↑", "Move up in search results"], ["↑", "Move up in search results"],
["↓", "Move down in search results"], ["↓", "Move down in search results"],
["← / →", "Switch result tab (when results focused)"], ["← / →", "Switch result tab (when results focused)"],

View File

@ -129,7 +129,7 @@
aria-label="Run search in the documentation" {#+ #} aria-label="Run search in the documentation" {#+ #}
autocomplete="off" {#+ #} autocomplete="off" {#+ #}
spellcheck="false" {#+ #} spellcheck="false" {#+ #}
placeholder="Click or press S to search, ? for more options…" {#+ #} placeholder="Type S or / to search, ? for more options…" {#+ #}
type="search"> {# #} type="search"> {# #}
<div id="help-button" tabindex="-1"> {# #} <div id="help-button" tabindex="-1"> {# #}
<a href="{{page.root_path|safe}}help.html" title="help">?</a> {# #} <a href="{{page.root_path|safe}}help.html" title="help">?</a> {# #}