Skip to content

Commit

Permalink
Merge branch 'enhancement/gh-4218-select2-choicejs' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
frjo committed Jan 27, 2025
2 parents c60bc4e + 11b20cf commit 55553e0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions hypha/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,14 @@
const selectElements = document.querySelectorAll("[data-js-choices]");

selectElements.forEach((selectElement) => {
new Choices(selectElement, {
shouldSort: false,
allowHTML: true,
removeItemButton: true,
});
if (!selectElement.hasChoicesInstance) {
const choicesInstance = new Choices(selectElement, {
shouldSort: false,
allowHTML: true,
removeItemButton: true,
});
selectElement.hasChoicesInstance = true;
};
});

const choicesElements = document.querySelectorAll(".choices__input--cloned")
Expand All @@ -146,7 +149,8 @@
const minWidth = window.getComputedStyle(choiceElement).getPropertyValue("min-width");
choiceElement.addEventListener("focus", () => {
if (choiceElement) {
choiceElement.placeholder = ""
choiceElement.placeholder = "Search..."
choiceElement.style.minWidth = '7ch';
}
});

Expand Down

0 comments on commit 55553e0

Please sign in to comment.