From c2021c3f7e0406755f4e30f3bf08270eb90584a7 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=utf8 Content-Transfer-Encoding: 8bit Sponsored-by: Büchereizentrale Schleswig-Holstein Signed-off-by: LEBSimonsen Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- 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 f70776b982..813b649849 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.39.5