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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user