diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 28df8d3f011fe..531c20a4f7b5f 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1036,7 +1036,7 @@ table, } /* pseudo-element for holding the dropdown-arrow image; needs to be a separate thing so that we can apply CSS-filters to change the arrow color in themes */ -#crate-search-div::after { +#crate-search::after { /* lets clicks through! */ pointer-events: none; /* completely covers the underlying div */ @@ -1669,6 +1669,28 @@ a.tooltip:hover::after { font-weight: normal; } +/* panel that only shows up during searches */ +#search-focus-panel { + position: absolute; + display: none; + background-color: var(--main-background-color); + border-width: 1px; + border-color: var(--border-color); + border-style: solid; + padding: 3px; + text-wrap: nowrap; + z-index: 1; + top: 0; +} + +rustdoc-search { + position: relative; +} + +rustdoc-search:focus-within #search-focus-panel { + display: block; +} + #src-sidebar { width: 100%; overflow: auto; diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index be0ec425946c2..4e8bc6d5047f4 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -2760,7 +2760,7 @@ ${item.displayPath}${name}\ * @param {boolean} go_to_first * @param {string} filterCrates */ - async function showResults(results, go_to_first, filterCrates) { + async function showResults(results, go_to_first, _filterCrates) { const search = searchState.outputElement(); if (go_to_first || (results.others.length === 1 && getSettingValue("go-to-only-result") === "true") @@ -2815,17 +2815,7 @@ ${item.displayPath}${name}\ } } - let crates = ""; - if (rawSearchIndex.size > 1) { - crates = " in 
"; - } - - let output = `

Results${crates}

`; + let output = "

Results

"; if (results.query.error !== null) { const error = results.query.error; error.forEach((value, index) => { @@ -3885,6 +3875,21 @@ ${item.displayPath}${name}\ exports.execQuery = execQuery; exports.parseQuery = parseQuery; } + + + let crates = "Searching in "; + if (rawSearchIndex.size > 1) { + crates += ""; + } else { + crates += rawSearchIndex.keys().next().value; + } + document.getElementById("crate-search-div").innerHTML = crates; } if (typeof window !== "undefined") { diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js index 4a27ca92fff38..18c67c3bf6e47 100644 --- a/src/librustdoc/html/static/js/storage.js +++ b/src/librustdoc/html/static/js/storage.js @@ -278,7 +278,8 @@ class RustdocSearchElement extends HTMLElement { - `; + +
loading crate list...
`; } } window.customElements.define("rustdoc-search", RustdocSearchElement);