From b62889a84f9f9355f25c7680c992e4c98a9b62c3 Mon Sep 17 00:00:00 2001 From: Samidy Date: Wed, 4 Feb 2026 16:53:43 +0300 Subject: [PATCH] fix(search): only log search AFTER unfocusing --- js/app.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/app.js b/js/app.js index c50caf5..b54a2ea 100644 --- a/js/app.js +++ b/js/app.js @@ -1276,7 +1276,6 @@ document.addEventListener('DOMContentLoaded', async () => { const performSearch = debounce((query) => { if (query) { - ui.addToSearchHistory(query); navigate(`/search/${encodeURIComponent(query)}`); } }, 300); @@ -1288,6 +1287,13 @@ document.addEventListener('DOMContentLoaded', async () => { } }); + searchInput.addEventListener('change', (e) => { + const query = e.target.value.trim(); + if (query.length > 2) { + ui.addToSearchHistory(query); + } + }); + searchInput.addEventListener('focus', () => { ui.renderSearchHistory(); }); @@ -1932,6 +1938,5 @@ function showKeyboardShortcuts() { }; modal.addEventListener('click', handleClose); - modal.classList.add('active'); -} +} \ No newline at end of file