From de7780b5e50320d3d29e652019e578765c4c72fd Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Wed, 17 Sep 2025 11:07:24 -0500 Subject: [PATCH] Don't save state to localStorage when filtering --- app/assets/stylesheets/popup.css | 3 ++- app/javascript/controllers/nav_section_expander_controller.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/popup.css b/app/assets/stylesheets/popup.css index c6035dedd..c864655a4 100644 --- a/app/assets/stylesheets/popup.css +++ b/app/assets/stylesheets/popup.css @@ -46,7 +46,8 @@ /* Hide lists when all the items within are hidden */ .popup__section { - &:has(.popup__section-title:only-child), + &:not(:has(.popup__list)), + &:not(:has(.popup__list > *)), &:has(.popup__item[hidden]):not(:has(.popup__item:not([hidden]))) { display: none; } diff --git a/app/javascript/controllers/nav_section_expander_controller.js b/app/javascript/controllers/nav_section_expander_controller.js index caba75a89..d0db6e014 100644 --- a/app/javascript/controllers/nav_section_expander_controller.js +++ b/app/javascript/controllers/nav_section_expander_controller.js @@ -10,6 +10,7 @@ export default class extends Controller { toggle(event) { const section = event.target + if (section.hasAttribute("data-is-filtering")) return const key = this.#localStorageKeyFor(section) if (section.open) { @@ -29,6 +30,7 @@ export default class extends Controller { #expandAll() { this.sectionTargets.forEach(section => { + section.setAttribute("data-is-filtering", true) section.open = true }) } @@ -37,6 +39,7 @@ export default class extends Controller { this.sectionTargets.forEach(section => { const key = this.#localStorageKeyFor(section) section.open = !localStorage.getItem(key) + section.removeAttribute("data-is-filtering") }) }