Only set query field when appropriate query param passed via URL

- Setting query value to default option when query param wasn't
  passed via URL was overriding placeholder text in query field

- We wanted placeholder text in field, not the query field to actually
  be populated by placeholder text

- This clears field when user starts typing query into the query field,
  instead of them having to manually delete the  default text populated
This commit is contained in:
Debanjum Singh Solanky
2022-07-31 22:29:23 +03:00
parent 17c38b526a
commit 0abd40aeb7

View File

@@ -85,7 +85,10 @@
// Fill search form with values passed in URL query parameters, if any.
window.onload = function () {
document.getElementById("type").value = new URLSearchParams(window.location.search).get("t") || "org";
document.getElementById("query").value = new URLSearchParams(window.location.search).get("q") || "What is the meaning of life?";
var query_via_url = new URLSearchParams(window.location.search).get("q");
if (query_via_url) {
document.getElementById("query").value = query_via_url;
}
}
</script>