« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/static/js
diff options
context:
space:
mode:
Diffstat (limited to 'src/static/js')
-rw-r--r--src/static/js/client/sidebar-search.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/static/js/client/sidebar-search.js b/src/static/js/client/sidebar-search.js
index b6008d28..051ba079 100644
--- a/src/static/js/client/sidebar-search.js
+++ b/src/static/js/client/sidebar-search.js
@@ -677,6 +677,8 @@ function clearSidebarSearch() {
 }
 
 function clearSidebarFilter() {
+  const {session} = info;
+
   toggleSidebarSearchFilter(session.activeFilterType);
 
   forEachFilter((_type, filterLink) => {
@@ -857,12 +859,13 @@ function showFilterElements(results) {
   let shownAny = false;
 
   forEachFilter((type, filterLink) => {
+    filterLink.classList.remove('shown', 'hidden');
+
     if (allReferenceTypes.includes(type)) {
       shownAny = true;
       cssProp(filterLink, 'display', null);
     } else {
       cssProp(filterLink, 'display', 'none');
-      filterLink.classList.remove('shown', 'hidden');
     }
   });
 
@@ -1211,8 +1214,10 @@ function toggleSidebarSearchFilter(toggleType) {
         filterLink.classList.add(filterActive ? 'shown' : 'hidden');
       }
 
-      shownAnyResults =
-        fillResultElements(session.activeQueryResults, {filterType});
+      if (session.activeQueryResults) {
+        shownAnyResults =
+          fillResultElements(session.activeQueryResults, {filterType});
+      }
 
       session.activeFilterType = filterType;
     } else {
@@ -1256,6 +1261,8 @@ function forgetRecentSidebarSearch() {
 
   session.activeQuery = null;
   session.activeQueryResults = null;
+
+  clearSidebarFilter();
 }
 
 async function handleDroppedIntoSearchInput(domEvent) {