Skip to content

Commit

Permalink
Rollup merge of rust-lang#66298 - Ppjet6:disable-search-field, r=Guil…
Browse files Browse the repository at this point in the history
…laumeGomez

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>
  • Loading branch information
Centril committed Nov 20, 2019
2 parents e32397a + 5721338 commit 00cbc75
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ pub fn render<T: Print, S: Print>(
</div>\
<script src=\"{static_root_path}theme{suffix}.js\"></script>\
<nav class=\"sub\">\
<form class=\"search-form js-only\">\
<form class=\"search-form\">\
<div class=\"search-container\">\
<div>{filter_crates}\
<input class=\"search-input\" name=\"search\" \
disabled \
autocomplete=\"off\" \
spellcheck=\"false\" \
placeholder=\"Click or press ‘S’ to search, ‘?’ for more options…\" \
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ function getSearchElement() {
var TY_PRIMITIVE = itemTypes.indexOf("primitive");
var TY_KEYWORD = itemTypes.indexOf("keyword");

onEachLazy(document.getElementsByClassName("js-only"), function(e) {
removeClass(e, "js-only");
});

function getQueryStringParams() {
var params = {};
window.location.search.substring(1).split("&").
Expand Down Expand Up @@ -2639,6 +2635,10 @@ function getSearchElement() {
option.innerText = crates_text[i];
elem.appendChild(option);
}

if (search_input) {
search_input.removeAttribute('disabled');
};
}

window.addSearchOptions = addSearchOptions;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ nav.sub {

/* Everything else */

.js-only, .hidden {
.hidden {
display: none !important;
}

Expand Down
4 changes: 4 additions & 0 deletions src/librustdoc/html/static/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ a.test-arrow {
border-color: #008dfd;
}

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

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

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

#crate-search + .search-input:focus {
box-shadow: 0 0 8px #078dd8;
}
Expand Down

0 comments on commit 00cbc75

Please sign in to comment.