Rollup merge of #50118 - GuillaumeGomez:search-bar-bug, r=QuietMisdreavus
fix search bar bug Fixes #50064. r? @QuietMisdreavus
This commit is contained in:
commit
05ef5bcb53
1 changed files with 18 additions and 10 deletions
|
@ -1375,13 +1375,17 @@
|
||||||
|
|
||||||
function search(e) {
|
function search(e) {
|
||||||
var params = getQueryStringParams();
|
var params = getQueryStringParams();
|
||||||
var query = getQuery(document.getElementsByClassName('search-input')[0].value.trim());
|
var search_input = document.getElementsByClassName('search-input')[0];
|
||||||
|
var query = getQuery(search_input.value.trim());
|
||||||
|
|
||||||
if (e) {
|
if (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!query.query || query.id === currentResults) {
|
if (!query.query || query.id === currentResults) {
|
||||||
|
if (query.query.length > 0) {
|
||||||
|
putBackSearch(search_input);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2072,19 +2076,23 @@
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function putBackSearch(search_input) {
|
||||||
|
if (search_input.value !== "") {
|
||||||
|
addClass(document.getElementById("main"), "hidden");
|
||||||
|
removeClass(document.getElementById("search"), "hidden");
|
||||||
|
if (browserSupportsHistoryApi()) {
|
||||||
|
history.replaceState(search_input.value,
|
||||||
|
"",
|
||||||
|
"?search=" + encodeURIComponent(search_input.value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var search_input = document.getElementsByClassName("search-input")[0];
|
var search_input = document.getElementsByClassName("search-input")[0];
|
||||||
|
|
||||||
if (search_input) {
|
if (search_input) {
|
||||||
search_input.onfocus = function() {
|
search_input.onfocus = function() {
|
||||||
if (search_input.value !== "") {
|
putBackSearch(this);
|
||||||
addClass(document.getElementById("main"), "hidden");
|
|
||||||
removeClass(document.getElementById("search"), "hidden");
|
|
||||||
if (browserSupportsHistoryApi()) {
|
|
||||||
history.replaceState(search_input.value,
|
|
||||||
"",
|
|
||||||
"?search=" + encodeURIComponent(search_input.value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue