Choices icon indicating copy to clipboard operation
Choices copied to clipboard

Class names can't contain spaces

Open mokhosh opened this issue 4 years ago • 5 comments

Describe the bug You can't add multiple classes and separate them with spaces. This is what you get:

Uncaught (in promise) DOMException: Failed to execute 'add' on 'DOMTokenList': The token provided ('bg-gray-200 p-1') contains HTML space characters, which are not valid in tokens

So you can't style this with tailwind. Or keep the original class and add a bootstrap class to it. The strange thing is you can do this for container and containerOuter but nothing else.

To Reproduce Steps to reproduce the behavior:

new Choices(element, {
  itemSelectText: '',
  removeItemButton: true,
  classNames: {
    containerOuter: 'choices bg-gray-200 focus:bg-gray-100 focus:shadow shadow-inner appearance-none rounded w-full text-gray-700 leading-tight',
    containerInner: 'py-1 px-3',
    input: 'bg-gray-200 p-1',
  },
});

mokhosh avatar Feb 29 '20 02:02 mokhosh

Can confirm.

aswinmohanme avatar Mar 10 '20 03:03 aswinmohanme

Can confirm as well (using tailwind).

nicobaguio avatar Mar 18 '20 17:03 nicobaguio

Anyone found a workaround for this?

hsleewis avatar Jun 30 '20 08:06 hsleewis

anybody gave a fix for this. It looks like this issue is for only certain classes and not all of them.

I face this issue when I add multiple classes to list, itemSelectable, listDropdown

Another issue that I have is that it doesn't append to the existing styles, it just replaces the existing styles. I use the base css of the plugin and want to use my own styles, so I was hoping they will append the classes to the class= attribute. I am hoping this is fixed as well.

abishekrsrikaanth avatar Jul 03 '20 17:07 abishekrsrikaanth

Is this still a bug? Bcz I try to add class with space to placeholder but it return a same error as the question

BariqDharmawan avatar Jun 07 '21 04:06 BariqDharmawan