From fa0d3c7e984d0a8888d08b63af8914ca0e5ffd5e Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 8 Jun 2023 10:03:53 +0200 Subject: [PATCH] cheat-sheet: Show no icons by default [why] The additional hints in the bottom are hard to notice if we flood users with all available items first. Usually users want to search the icons and not browse, so showing them all per default seems better. [how] Just do not change the search term from "" to something else, so the search comes up empty on an empty search. If people search for a blank the previous mechanics to show all icons is triggered instead. A message to hint for this is added to the empty search result. Signed-off-by: Fini Jastrow --- cheat-sheet.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cheat-sheet.js b/cheat-sheet.js index 875a2a9b7..2e1d4d97f 100644 --- a/cheat-sheet.js +++ b/cheat-sheet.js @@ -127,12 +127,17 @@ document.addEventListener('DOMContentLoaded', function () { function searchGlyphs() { let searchTerm = elementGlyphSearch.value; - let prefixSearchEnabled = true + let prefixSearchEnabled = true; + let emptyResultsMessage = `No matches found`; if (searchTerm === "") { - // MiniSearch don't allow empty searches, so we search for "nf". - searchTerm = "nf"; - prefixSearchEnabled = false; + // MiniSearch doesn't allow empty searches and we want to show the bottom info + emptyResultsMessage = "Enter (part) of a word to search for or enter space / blank (' ') to show all icons" + } else { + if (searchTerm === " ") { + prefixSearchEnabled = false; + searchTerm = "nf"; + } } // TODO: search suggestions @@ -157,7 +162,7 @@ document.addEventListener('DOMContentLoaded', function () { } else { let notFoundElem = document.createElement("div"); notFoundElem.setAttribute("style", "padding: 10px;"); - notFoundElem.innerHTML = `No matches found`; + notFoundElem.innerHTML = emptyResultsMessage; elementGlyphCheatSheet.appendChild(notFoundElem); }