Skip to content

Commit 00cbc75

Browse files
authored
Rollup merge of rust-lang#66298 - Ppjet6:disable-search-field, r=GuillaumeGomez
rustdoc: fixes rust-lang#64305: disable search field instead of hidding it The result seems to be ok but I wasn't entirely sure how to get there. I tried to stay generic a bit but maybe it's not required at all. @GuillaumeGomez Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2 parents e32397a + 5721338 commit 00cbc75

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

src/librustdoc/html/layout.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ pub fn render<T: Print, S: Print>(
8787
</div>\
8888
<script src=\"{static_root_path}theme{suffix}.js\"></script>\
8989
<nav class=\"sub\">\
90-
<form class=\"search-form js-only\">\
90+
<form class=\"search-form\">\
9191
<div class=\"search-container\">\
9292
<div>{filter_crates}\
9393
<input class=\"search-input\" name=\"search\" \
94+
disabled \
9495
autocomplete=\"off\" \
9596
spellcheck=\"false\" \
9697
placeholder=\"Click or press ‘S’ to search, ‘?’ for more options…\" \

src/librustdoc/html/static/main.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ function getSearchElement() {
142142
var TY_PRIMITIVE = itemTypes.indexOf("primitive");
143143
var TY_KEYWORD = itemTypes.indexOf("keyword");
144144

145-
onEachLazy(document.getElementsByClassName("js-only"), function(e) {
146-
removeClass(e, "js-only");
147-
});
148-
149145
function getQueryStringParams() {
150146
var params = {};
151147
window.location.search.substring(1).split("&").
@@ -2639,6 +2635,10 @@ function getSearchElement() {
26392635
option.innerText = crates_text[i];
26402636
elem.appendChild(option);
26412637
}
2638+
2639+
if (search_input) {
2640+
search_input.removeAttribute('disabled');
2641+
};
26422642
}
26432643

26442644
window.addSearchOptions = addSearchOptions;

src/librustdoc/html/static/rustdoc.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ nav.sub {
203203

204204
/* Everything else */
205205

206-
.js-only, .hidden {
206+
.hidden {
207207
display: none !important;
208208
}
209209

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

+4
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ a.test-arrow {
177177
border-color: #008dfd;
178178
}
179179

180+
.search-focus:disabled {
181+
background-color: #c5c4c4;
182+
}
183+
180184
#crate-search + .search-input:focus {
181185
box-shadow: 0 0 8px 4px #078dd8;
182186
}

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

+4
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ a.test-arrow {
177177
border-color: #66afe9;
178178
}
179179

180+
.search-focus:disabled {
181+
background-color: #e6e6e6;
182+
}
183+
180184
#crate-search + .search-input:focus {
181185
box-shadow: 0 0 8px #078dd8;
182186
}

0 commit comments

Comments
 (0)