feat(search): hide "clear search" icon if input is empty (#388)

main
Óscar 5 months ago committed by GitHub
parent 0bebcd1c6d
commit 1ffe43f934
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -28,6 +28,7 @@ $icon-size: 1.3rem;
}
.close-icon {
display: none;
position: absolute;
right: $icon-size;
margin-inline-start: 1rem;

@ -2675,6 +2675,7 @@ window.onload = function () {
results.innerHTML = '';
resultsContainer.style.display = 'none';
searchInput.removeAttribute('aria-activedescendant');
clearSearchButton.style.display = 'none';
}
// Close modal when clicking/tapping outside.
@ -2941,10 +2942,13 @@ window.onload = function () {
searchInput.addEventListener(
'input',
async function () {
const searchTerm = this.value.trim();
const searchInput = this.value;
const searchTerm = searchInput.trim();
const searchIndex = await searchIndexPromise;
results.innerHTML = '';
// Use the raw input so the "clear" button appears even if there's only spaces.
clearSearchButton.style.display = searchInput.length > 0 ? 'block' : 'none';
resultsContainer.style.display = searchTerm.length > 0 ? 'block' : 'none';
// Perform the search and store the results.

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save