diff --git a/app/javascript/controllers/multi_selection_combobox_controller.js b/app/javascript/controllers/multi_selection_combobox_controller.js index 716420839..9f2937de5 100644 --- a/app/javascript/controllers/multi_selection_combobox_controller.js +++ b/app/javascript/controllers/multi_selection_combobox_controller.js @@ -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) + } }