From 0d083f53e732afa555ea10e4368771237c2cfbd2 Mon Sep 17 00:00:00 2001 From: partisan Date: Sat, 16 Nov 2024 12:34:40 +0100 Subject: [PATCH] Fix incorrect links in search suggestions --- static/js/autocomplete.js | 10 +++++++--- templates/files.html | 1 + templates/forums.html | 1 + templates/images.html | 1 + templates/map.html | 1 + templates/text.html | 1 + templates/videos.html | 1 + 7 files changed, 13 insertions(+), 3 deletions(-) diff --git a/static/js/autocomplete.js b/static/js/autocomplete.js index 6f1c19b..7bdbb14 100644 --- a/static/js/autocomplete.js +++ b/static/js/autocomplete.js @@ -101,9 +101,13 @@ document.addEventListener('DOMContentLoaded', () => { searchInput.value = query; resultsWrapper.innerHTML = ''; searchWrapper.classList.remove('wrapper-searching'); - const form = searchInput.closest('form'); - form ? form.submit() : window.location.href = `/search?q=${encodeURIComponent(query)}&t=web`; - } + + // Retrieve the `t` parameter from the hidden input or set a default + const currentTemplateType = document.querySelector('input[name="t"]').value || 'web'; + + // Redirect to the appropriate results page + window.location.href = `/search?q=${encodeURIComponent(query)}&t=${encodeURIComponent(currentTemplateType)}`; + } // Handle clicks on search suggestions resultsWrapper.addEventListener('click', (event) => { diff --git a/templates/files.html b/templates/files.html index c25751d..b344339 100755 --- a/templates/files.html +++ b/templates/files.html @@ -17,6 +17,7 @@
+