From 46c0f7de2e132d2521ab533fc29517acd4593e8c Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Thu, 24 Oct 2024 14:41:39 +0000 Subject: [PATCH] Bug 38222: (follow-up) Minimally initialize combobox if passed no data via constructor or referenced elements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sponsored-by: Büchereizentrale Schleswig-Holstein Signed-off-by: LEBSimonsen Signed-off-by: Martin Renvoize --- koha-tmpl/intranet-tmpl/prog/js/combobox.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/combobox.js b/koha-tmpl/intranet-tmpl/prog/js/combobox.js index f70776b9822..813b6498498 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/combobox.js +++ b/koha-tmpl/intranet-tmpl/prog/js/combobox.js @@ -78,12 +78,19 @@ }) .filter(option => option !== null); - const combinedData = [...existingOptions, ...data]; - let selectedValue = null; let query = ""; let focusedIndex = -1; + const combinedData = [...existingOptions, ...data]; + if (!combinedData?.length) { + dropdownMenu.style.display = "none"; + return { + getSelectedValue: () => selectedValue, + reset, + }; + } + // Setup input attributes input.setAttribute("placeholder", placeholder); input.setAttribute("aria-expanded", "false"); -- 2.47.0