Choices-js / Choices

A vanilla JS customisable select box/text input plugin ⚡️
https://choices-js.github.io/Choices/
MIT License
6.25k stars 617 forks source link

Add an option to hide the drop down arrow (or the complete drop down including arrow) for "no choice inputs" #1213

Open marcopenhacking opened 2 months ago

marcopenhacking commented 2 months ago

Is your feature request related to a problem? Please describe. I like to have an easy way using an option to hide the drop down arrow (marked yellow). This is to made a special input field with just one pre-defined data selection look the same like other input field with multiple choices on the same page.

image

Describe the solution you'd like Add an option removeDropDownButton (for just arrow) or removeDropDown to remove the drop down completely with the arrow button

This removes the drop-down but not the drop down arrow:

        callbackOnCreateTemplates: function(template) {
            return {
              dropdown: (classNames, isSelectOne) => {
                return template(`
                  <div class="${classNames.listDropdown} choices__list--hidden"></div>
                `);
              }
            };
        }

...
document.addEventListener('DOMContentLoaded', (event) => {
    const dropdown = document.querySelector('.choices__list--hidden');
    if (dropdown) {
      dropdown.remove();
    }
  });
...

Describe alternatives you've considered Suppress the button using CSS. My first attempts failed.

Additional context Add any other context or screenshots about the feature request here.