Skip to content

Commit 6d4b4d9

Browse files
committed
rustdoc-search: keep hourglass in searchbar
1 parent 5c31880 commit 6d4b4d9

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

src/librustdoc/html/static/css/rustdoc.css

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ summary.hideme,
339339
.scraped-example-list,
340340
.rustdoc-breadcrumbs,
341341
.search-switcher,
342-
.search-throbber,
343342
/* This selector is for the items listed in the "all items" page. */
344343
ul.all-items {
345344
font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif;
@@ -2007,12 +2006,6 @@ a.tooltip:hover::after {
20072006
color: transparent;
20082007
}
20092008

2010-
.search-throbber {
2011-
position: relative;
2012-
height: 34px;
2013-
}
2014-
2015-
.search-throbber::after,
20162009
.search-form.loading::after
20172010
{
20182011
width: 18px;

src/librustdoc/html/static/js/search.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ignore-tidy-filelength
2-
/* global addClass, getNakedUrl, getVar, nonnull, getSettingValue */
2+
/* global addClass, getNakedUrl, getVar, getSettingValue, hasClass, nonnull */
33
/* global onEachLazy, removeClass, searchState, browserSupportsHistoryApi */
44

55
"use strict";
@@ -4804,6 +4804,15 @@ function printTab(nb) {
48044804
if (nb === iter) {
48054805
addClass(elem, "selected");
48064806
foundCurrentTab = true;
4807+
onEachLazy(document.querySelectorAll(
4808+
".search-form",
4809+
), form => {
4810+
if (hasClass(elem.firstElementChild, "loading")) {
4811+
addClass(form, "loading");
4812+
} else {
4813+
removeClass(form, "loading");
4814+
}
4815+
});
48074816
} else {
48084817
removeClass(elem, "selected");
48094818
}
@@ -4904,11 +4913,6 @@ async function addTab(results, query, display, finishedCallback, isTypeSearch) {
49044913
let output = document.createElement("ul");
49054914
output.className = "search-results " + extraClass;
49064915

4907-
const throbber = document.createElement("div");
4908-
throbber.className = "search-throbber";
4909-
throbber.innerHTML = "Loading...";
4910-
output.appendChild(throbber);
4911-
49124916
let count = 0;
49134917

49144918
/** @type {Promise<string|null>[]} */
@@ -5015,7 +5019,7 @@ ${obj.displayPath}<span class="${type}">${name}</span>\
50155019
}
50165020

50175021
link.appendChild(description);
5018-
output.insertBefore(link, throbber);
5022+
output.appendChild(link);
50195023

50205024
results.next().then(async nextResult => {
50215025
if (nextResult.value) {
@@ -5026,7 +5030,6 @@ ${obj.displayPath}<span class="${type}">${name}</span>\
50265030
// running this callback
50275031
yieldToBrowser().then(() => {
50285032
finishedCallback(count, output);
5029-
throbber.remove();
50305033
});
50315034
}
50325035
});
@@ -5164,6 +5167,7 @@ function makeTab(tabNb, text, results, query, isTypeSearch, goToFirst) {
51645167
count < 100 ? `\u{2007}(${count})\u{2007}` : `\u{2007}(${count})`;
51655168
tabCount.innerHTML = fmtNbElems;
51665169
tabCount.className = "count";
5170+
printTab(window.searchState.currentTab);
51675171
}, isTypeSearch),
51685172
];
51695173
}
@@ -5227,9 +5231,7 @@ async function showResults(docSearch, results, goToFirst, filterCrates) {
52275231
tabsElem.appendChild(tab);
52285232
const isCurrentTab = window.searchState.currentTab === tabNb;
52295233
const placeholder = document.createElement("div");
5230-
placeholder.className = isCurrentTab ?
5231-
"search-throbber search-results active" :
5232-
"search-throbber search-results";
5234+
placeholder.className = isCurrentTab ? "search-results active" : "search-results";
52335235
placeholder.innerHTML = "Loading...";
52345236
output.then(output => {
52355237
if (placeholder.parentElement) {
@@ -5487,11 +5489,6 @@ if (ROOT_PATH === null) {
54875489
const database = await Stringdex.loadDatabase(hooks);
54885490
if (typeof window !== "undefined") {
54895491
docSearch = new DocSearch(ROOT_PATH, database);
5490-
onEachLazy(document.querySelectorAll(
5491-
".search-form.loading",
5492-
), form => {
5493-
removeClass(form, "loading");
5494-
});
54955492
registerSearchEvents();
54965493
// If there's a search term in the URL, execute the search now.
54975494
if (window.searchState.getQueryStringParams().search !== undefined) {

0 commit comments

Comments
 (0)