From c3d1ebe505a8ef331e24310bf74687edcff6194b 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 --- 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.47.0