From 717ee86d27d5d8d390a09ce1e692b2d4ec7fbca4 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Mon, 1 Dec 2025 16:36:28 -0600 Subject: [PATCH] Update show attribute when refreshing to correctly hide the field when unselected Previously it would hang around and bleed in the terms input --- .../controllers/multi_selection_combobox_controller.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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) + } }