diff --git a/static/skin/viewer.js b/static/skin/viewer.js
index c10c599c9..971c21220 100644
--- a/static/skin/viewer.js
+++ b/static/skin/viewer.js
@@ -125,7 +125,17 @@ function getSearchPattern() {
return null;
}
+
+let autoCompleteJS = null;
+
+function closeSuggestions() {
+ if ( autoCompleteJS ) {
+ autoCompleteJS.close();
+ }
+}
+
function updateSearchBoxForLocationChange() {
+ closeSuggestions();
document.getElementById("kiwixsearchbox").value = getSearchPattern();
}
@@ -217,7 +227,7 @@ document.addEventListener('DOMContentLoaded', function () {
const kiwixSearchBox = document.querySelector('#kiwixsearchbox');
const kiwixSearchFormWrapper = document.querySelector('.kiwix_searchform');
- const autoCompleteJS = new autoComplete(
+ autoCompleteJS = new autoComplete(
{
selector: "#kiwixsearchbox",
placeHolder: kiwixSearchBox.title,
@@ -263,6 +273,7 @@ document.addEventListener('DOMContentLoaded', function () {
);
document.querySelector('#kiwixsearchform').addEventListener('submit', function(event) {
+ closeSuggestions();
try {
const selectedElem = document.querySelector('.autoComplete_selected > a');
if (selectedElem) {
diff --git a/test/server.cpp b/test/server.cpp
index 2d7d6f3e9..93bd9f4b5 100644
--- a/test/server.cpp
+++ b/test/server.cpp
@@ -202,7 +202,7 @@ R"EXPECTEDRESULT(
-
+
const blankPageUrl = `${root}/skin/blank.html`;