From 8b6058c879606ccd4fb12a1138728e21c6dccb46 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 1 Aug 2022 00:03:52 +0300 Subject: [PATCH] Fix instantiating type field with value from URL query parameter - Populate via `.then` after enabled search types in dropdown are populated - Call to `/config` API is async and will usually complete after the value of type field is set from url - So value of type field would earlier be overridden when search types dropdown is populated after the call to `/config` API completes --- src/interface/web/index.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/interface/web/index.html b/src/interface/web/index.html index 1229d9b8..333abc19 100644 --- a/src/interface/web/index.html +++ b/src/interface/web/index.html @@ -93,12 +93,13 @@ .filter(type => data["content-type"].hasOwnProperty(type) && data["content-type"][type]) .map(type => ``) .join(''); + }) + .then(() => { + // Set type field to search type passed in URL query parameter, if valid + var type_via_url = new URLSearchParams(window.location.search).get("t"); + if (type_via_url && possible_search_types.includes(type_via_url)) + document.getElementById("type").value = type_via_url; }); - - // Set type field to search type passed in URL query parameter, if valid - var type_via_url = new URLSearchParams(window.location.search).get("t"); - if (type_via_url && type_via_url in possible_search_types) - document.getElementById("type").value = type_via_url; } window.onload = function () { @@ -107,9 +108,8 @@ // Fill query field with value passed in URL query parameters, if any. var query_via_url = new URLSearchParams(window.location.search).get("q"); - if (query_via_url) { + if (query_via_url) document.getElementById("query").value = query_via_url; - } }