Skip to content

Commit 3dc922d

Browse files
committed
Show loading throbber on the input field during initial load
1 parent 4ab3c31 commit 3dc922d

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,13 @@ a.tooltip:hover::after {
19551955
color: transparent;
19561956
}
19571957

1958-
#search-tabs .count.loading::before {
1958+
.search-form.loading {
1959+
--search-tab-button-background: var(--button-background-color);
1960+
}
1961+
1962+
#search-tabs .count.loading::before,
1963+
.search-form.loading::before
1964+
{
19591965
width: 16px;
19601966
height: 16px;
19611967
border-radius: 16px;
@@ -1982,7 +1988,9 @@ a.tooltip:hover::after {
19821988
top: 2px;
19831989
animation: rotating 1.25s linear infinite;
19841990
}
1985-
#search-tabs .count.loading::after {
1991+
#search-tabs .count.loading::after,
1992+
.search-form.loading::after
1993+
{
19861994
width: 18px;
19871995
height: 18px;
19881996
border-radius: 18px;
@@ -1997,6 +2005,18 @@ a.tooltip:hover::after {
19972005
animation: rotating 0.66s linear infinite;
19982006
}
19992007

2008+
.search-form.loading::before {
2009+
left: auto;
2010+
right: 9px;
2011+
top: 8px;
2012+
}
2013+
2014+
.search-form.loading::after {
2015+
left: auto;
2016+
right: 8px;
2017+
top: 8px;
2018+
}
2019+
20002020
#search .error code {
20012021
border-radius: 3px;
20022022
background-color: var(--search-error-code-background-color);

src/librustdoc/html/static/js/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ function preLoadCss(cssUrl) {
256256
const params = window.searchState.getQueryStringParams();
257257
const autofocusParam = params.search === "" ? "autofocus" : "";
258258
hdr.innerHTML = `<nav class="sub">
259-
<form class="search-form">
259+
<form class="search-form loading">
260260
<span></span> <!-- This empty span is a hacky fix for Safari: see #93184 -->
261261
<input
262262
${autofocusParam}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5075,6 +5075,11 @@ const database = await Stringdex.loadDatabase(hooks);
50755075
if (typeof window !== "undefined") {
50765076
docSearch = new DocSearch(ROOT_PATH, database);
50775077
await docSearch.buildIndex();
5078+
onEachLazy(document.querySelectorAll(
5079+
".search-form.loading",
5080+
), form => {
5081+
removeClass(form, "loading");
5082+
});
50785083
registerSearchEvents();
50795084
// If there's a search term in the URL, execute the search now.
50805085
if (window.searchState.getQueryStringParams().search !== undefined) {

0 commit comments

Comments
 (0)