Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled options are not visible (using remote source to populate data) #1257

Open
bboy-space opened this issue Jan 22, 2025 · 0 comments
Open
Labels

Comments

@bboy-space
Copy link

bboy-space commented Jan 22, 2025

Hello,
first of all thank you for this library but I am struggling trying to disable options using remote populate.

Describe the bug
My Choices options are populated through a remote webservice (by the way a settings options giving the fetchUrl and fetchCallback would be better than addEventListener on search but that's another story). Among the options returned by the webservice, some options need to be disabled because I explicitly want to display them (For example i want to show the user has been found but he's disabled, i mean not clickable).
Problem is , if i set disabled = true to my choice item, the option is not showing anymore.
I am using callbackOnCreateTemplates to custom the display.

To Reproduce
Steps to reproduce the behavior:

  1. addEventListener('search') fetching remote webservice

  2. in the callback promise, map the json data with {id, value, label, disabled} like :
    results.push({
    value: user.id,
    label: user.firstname + ' ' + user.lastname,
    disabled: user.disabled
    })

  3. I tried to find a workaround using customProperties.disabled and not directly the property disabled. So in the callbackOnCreateTemplates i am using the correct classes. And then my user is displayed with the gray disabled class but still clickable and added (this is not what i want)

  4. See errorExpected behavior

Screenshots
On the screenshot is an example of the customProperties.disabled = true . As you can see the disabled classes are correct but user is still clickable . For my example all the users are disabled.
Image

Choices version and bundle

  • Version: [v11.0.3 choices.min.js]

Thank you for help

@bboy-space bboy-space added the bug label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant