From bd41516190a17dc4ab6bde26214944148e9dbe4f Mon Sep 17 00:00:00 2001 From: alistair3149 Date: Tue, 22 Aug 2023 14:20:54 -0700 Subject: [PATCH] =?UTF-8?q?fix(search):=20=F0=9F=90=9B=20do=20not=20add=20?= =?UTF-8?q?empty=20term=20to=20search=20history?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/skins.citizen.search/typeahead.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/skins.citizen.search/typeahead.js b/resources/skins.citizen.search/typeahead.js index 0305c3ad..389699bd 100644 --- a/resources/skins.citizen.search/typeahead.js +++ b/resources/skins.citizen.search/typeahead.js @@ -194,14 +194,15 @@ const typeahead = { const item = event.target.closest( '.citizen-typeahead__item' ); if ( item instanceof HTMLElement ) { let historyLabel; - // User click on a suggestion -> save the matched title > title if ( item.classList.contains( 'citizen-typeahead__item-page' ) ) { - historyLabel = item.querySelector( '.citizen-typeahead__label' ).innerText ?? item.querySelector( '.citizen-typeahead__title' ).innerText; + historyLabel = item.querySelector( '.citizen-typeahead__label' ).innerText || item.querySelector( '.citizen-typeahead__title' ).innerText; } else { historyLabel = searchQuery.value; } - searchHistory.add( historyLabel ); + if ( historyLabel ) { + searchHistory.add( historyLabel ); + } } } },