Update show attribute when refreshing to correctly hide the field when unselected

Previously it would hang around and bleed in the terms input
This commit is contained in:
Jason Zimdars
2025-12-01 16:36:28 -06:00
parent e32ec6f5e9
commit 717ee86d27
@@ -26,12 +26,14 @@ export default class extends Controller {
refresh() {
this.labelTarget.textContent = this.#selectedLabel
this.#updateHiddenFields()
this.#updateFilterShow()
}
clear(event) {
this.#deselectAll()
this.#updateHiddenFields()
this.labelTarget.textContent = this.#selectedLabel
this.#updateFilterShow()
}
get #selectedLabel() {
@@ -80,6 +82,7 @@ export default class extends Controller {
#updateHiddenFields() {
this.#clearHiddenFields()
this.#addHiddenFields()
this.#updateFilterShow()
}
#deselectAll() {
@@ -122,4 +125,9 @@ export default class extends Controller {
this.element.appendChild(field)
})
}
#updateFilterShow() {
const hasSelection = this.#selectedValues().length > 0
this.element.setAttribute("data-filter-show", hasSelection)
}
}