Skip to content

Commit 19b5e4d

Browse files
committed
Show loading throbber on the input field during initial load
1 parent dcf3ac6 commit 19b5e4d

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
@@ -1959,7 +1959,13 @@ a.tooltip:hover::after {
19591959
color: transparent;
19601960
}
19611961

1962-
#search-tabs .count.loading::before {
1962+
.search-form.loading {
1963+
--search-tab-button-background: var(--button-background-color);
1964+
}
1965+
1966+
#search-tabs .count.loading::before,
1967+
.search-form.loading::before
1968+
{
19631969
width: 16px;
19641970
height: 16px;
19651971
border-radius: 16px;
@@ -1986,7 +1992,9 @@ a.tooltip:hover::after {
19861992
top: 2px;
19871993
animation: rotating 1.25s linear infinite;
19881994
}
1989-
#search-tabs .count.loading::after {
1995+
#search-tabs .count.loading::after,
1996+
.search-form.loading::after
1997+
{
19901998
width: 18px;
19911999
height: 18px;
19922000
border-radius: 18px;
@@ -2001,6 +2009,18 @@ a.tooltip:hover::after {
20012009
animation: rotating 0.66s linear infinite;
20022010
}
20032011

2012+
.search-form.loading::before {
2013+
left: auto;
2014+
right: 9px;
2015+
top: 8px;
2016+
}
2017+
2018+
.search-form.loading::after {
2019+
left: auto;
2020+
right: 8px;
2021+
top: 8px;
2022+
}
2023+
20042024
#search .error code {
20052025
border-radius: 3px;
20062026
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)