Skip to content

Commit bb6901d

Browse files
authored
Rollup merge of #90333 - jsha:flashy-searchbar, r=GuillaumeGomez
rustdoc: remove flicker during page load The search bar has a `:disabled` style that makes it grey, which creates a distracting flicker from grey to white when the page finishes loading. The search bar should stay the same color throughout page load. A blank white search bar might create an incorrect impression for users with JS turned off. Since they can't use the search functionality, I've hidden the search bar in noscript.css. Fixes #90246 r? `@GuillaumeGomez` Demo: https://rustdoc.crud.net/jsha/flashy-searchbar/std/string/struct.String.html
2 parents b7be4fc + a4fe76f commit bb6901d

File tree

7 files changed

+18
-14
lines changed

7 files changed

+18
-14
lines changed

src/librustdoc/html/static/css/noscript.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,12 @@ rules.
1313
/* It requires JS to work so no need to display it in this case. */
1414
display: none;
1515
}
16+
17+
.sub {
18+
/* The search bar and related controls don't work without JS */
19+
display: none;
20+
}
21+
22+
#theme-picker {
23+
display: none;
24+
}

src/librustdoc/html/static/css/themes/ayu.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,6 @@ details.undocumented > summary::before {
255255
box-shadow: 0 0 0 1px #148099,0 0 0 2px transparent;
256256
}
257257

258-
.search-input:disabled {
259-
background-color: #3e3e3e;
260-
}
261-
262258
.module-item .stab,
263259
.import-item .stab {
264260
color: #000;

src/librustdoc/html/static/css/themes/dark.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,6 @@ details.undocumented > summary::before {
219219
border-color: #008dfd;
220220
}
221221

222-
.search-input:disabled {
223-
background-color: #c5c4c4;
224-
}
225-
226222
#crate-search + .search-input:focus {
227223
box-shadow: 0 0 8px 4px #078dd8;
228224
}

src/librustdoc/html/static/css/themes/light.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@ details.undocumented > summary::before {
209209
border-color: #66afe9;
210210
}
211211

212-
.search-input:disabled {
213-
background-color: #e6e6e6;
214-
}
215-
216212
#crate-search + .search-input:focus {
217213
box-shadow: 0 0 8px #078dd8;
218214
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ function hideThemeButtonState() {
263263
search_input.placeholder = searchState.input.origPlaceholder;
264264
});
265265

266-
search_input.removeAttribute('disabled');
266+
if (search_input.value != '') {
267+
loadSearch();
268+
}
267269

268270
// `crates{version}.js` should always be loaded before this script, so we can use it
269271
// safely.

src/librustdoc/html/templates/page.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
<input {# -#}
8686
class="search-input" {# -#}
8787
name="search" {# -#}
88-
disabled {# -#}
8988
autocomplete="off" {# -#}
9089
spellcheck="false" {# -#}
9190
placeholder="Click or press ‘S’ to search, ‘?’ for more options…" {# -#}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// When JavaScript is disabled, we hide the search bar, because it
2+
// can't be used without JS.
3+
javascript: false
4+
5+
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
6+
assert-css: (".sub", {"display": "none"})

0 commit comments

Comments
 (0)