Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: remove flicker during page load #90333

Merged
merged 1 commit into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/librustdoc/html/static/css/noscript.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ rules.
/* It requires JS to work so no need to display it in this case. */
display: none;
}

.sub {
/* The search bar and related controls don't work without JS */
display: none;
jsha marked this conversation as resolved.
Show resolved Hide resolved
}

#theme-picker {
display: none;
}
4 changes: 0 additions & 4 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,6 @@ details.undocumented > summary::before {
box-shadow: 0 0 0 1px #148099,0 0 0 2px transparent;
}

.search-input:disabled {
background-color: #3e3e3e;
}

.module-item .stab,
.import-item .stab {
color: #000;
Expand Down
4 changes: 0 additions & 4 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,6 @@ details.undocumented > summary::before {
border-color: #008dfd;
}

.search-input:disabled {
background-color: #c5c4c4;
}

#crate-search + .search-input:focus {
box-shadow: 0 0 8px 4px #078dd8;
}
Expand Down
4 changes: 0 additions & 4 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,6 @@ details.undocumented > summary::before {
border-color: #66afe9;
}

.search-input:disabled {
background-color: #e6e6e6;
}

#crate-search + .search-input:focus {
box-shadow: 0 0 8px #078dd8;
}
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ function hideThemeButtonState() {
search_input.placeholder = searchState.input.origPlaceholder;
});

search_input.removeAttribute('disabled');
if (search_input.value != '') {
loadSearch();
jsha marked this conversation as resolved.
Show resolved Hide resolved
}

// `crates{version}.js` should always be loaded before this script, so we can use it
// safely.
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/html/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
<input {# -#}
class="search-input" {# -#}
name="search" {# -#}
disabled {# -#}
autocomplete="off" {# -#}
spellcheck="false" {# -#}
placeholder="Click or press ‘S’ to search, ‘?’ for more options…" {# -#}
Expand Down
6 changes: 6 additions & 0 deletions src/test/rustdoc-gui/javascript-disabled.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// When JavaScript is disabled, we hide the search bar, because it
// can't be used without JS.
javascript: false
jsha marked this conversation as resolved.
Show resolved Hide resolved

goto: file://|DOC_PATH|/test_docs/struct.Foo.html
assert-css: (".sub", {"display": "none"})