Skip to content

Commit

Permalink
Hide search bar in noscript.css
Browse files Browse the repository at this point in the history
Also, remove the highlighting of the search bar in disabled state. This
reduces flicker when loading a page.
  • Loading branch information
jsha committed Oct 31, 2021
1 parent c7e4740 commit a4fe76f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
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;
}

#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();
}

// `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

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

0 comments on commit a4fe76f

Please sign in to comment.