diff --git a/war/src/main/js/components/dropdowns/hetero-list.js b/war/src/main/js/components/dropdowns/hetero-list.js index a2fb6d62433d..2b216bc20168 100644 --- a/war/src/main/js/components/dropdowns/hetero-list.js +++ b/war/src/main/js/components/dropdowns/hetero-list.js @@ -21,6 +21,23 @@ function generateHandles() { }); } +function convertInputsToButtons(e) { + let oldInputs = e.querySelectorAll("INPUT.hetero-list-add"); + oldInputs.forEach((oldbtn) => { + let btn = document.createElement("button"); + btn.setAttribute("type", "button"); + btn.classList.add("hetero-list-add", "jenkins-button"); + btn.innerText = oldbtn.getAttribute("value"); + if (oldbtn.hasAttribute("suffix")) { + btn.setAttribute("suffix", oldbtn.getAttribute("suffix")); + } + let chevron = createElementFromHtml(Symbols.CHEVRON_DOWN); + btn.appendChild(chevron); + oldbtn.parentNode.appendChild(btn); + oldbtn.remove(); + }); +} + function generateButtons() { behaviorShim.specify( "DIV.hetero-list-container", @@ -31,26 +48,8 @@ function generateButtons() { return; } + convertInputsToButtons(e); let btn = Array.from(e.querySelectorAll("BUTTON.hetero-list-add")).pop(); - if (!btn) { - let oldbtn = Array.from( - e.querySelectorAll("INPUT.hetero-list-add"), - ).pop(); - if (!oldbtn) { - return; - } - btn = document.createElement("button"); - btn.setAttribute("type", "button"); - btn.classList.add("hetero-list-add", "jenkins-button"); - btn.innerText = oldbtn.getAttribute("value"); - if (oldbtn.hasAttribute("suffix")) { - btn.setAttribute("suffix", oldbtn.getAttribute("suffix")); - } - let chevron = createElementFromHtml(Symbols.CHEVRON_DOWN); - btn.appendChild(chevron); - oldbtn.parentNode.appendChild(btn); - oldbtn.remove(); - } let prototypes = e.lastElementChild; while (!prototypes.classList.contains("prototypes")) {