diff --git a/src/renderer/html_handlebars/search.rs b/src/renderer/html_handlebars/search.rs
index 01ef44ac..942a15b5 100644
--- a/src/renderer/html_handlebars/search.rs
+++ b/src/renderer/html_handlebars/search.rs
@@ -69,7 +69,7 @@ pub fn create_files(
// To reduce the size of the generated JSON by preventing all `"` characters to be
// escaped, we instead surround the string with much less common `'` character.
format!(
- "window.search = JSON.parse('{}');",
+ "window.search = Object.assign(window.search, JSON.parse('{}'));",
index.replace("\\", "\\\\").replace("'", "\\'")
)
.as_bytes(),
diff --git a/tests/gui/search.goml b/tests/gui/search.goml
index a49d9f7b..ae172b43 100644
--- a/tests/gui/search.goml
+++ b/tests/gui/search.goml
@@ -1,5 +1,6 @@
// This tests basic search behavior.
+fail-on-js-error: true
go-to: |DOC_PATH| + "index.html"
define-function: (
@@ -41,6 +42,9 @@ press-key: 's'
wait-for-css-false: ("#search-wrapper", {"display": "none"})
// We ensure the search bar has the focus.
assert: "#searchbar:focus"
+// Pressing a key will therefore update the search input.
+press-key: 't'
+assert-text: ("#searchbar", "t")
// Now we press `Escape` to ensure that the search input disappears again.
press-key: 'Escape'