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

Clearable selection on single select #2657

Closed
chrisidakwo opened this issue Sep 20, 2021 · 3 comments
Closed

Clearable selection on single select #2657

chrisidakwo opened this issue Sep 20, 2021 · 3 comments

Comments

@chrisidakwo
Copy link

I have a use case where a user can decide to deselect an already selected option in order to leave the select element without a selected value, I've looked around and it appears this plugin doesn't supports something like that.

Currently, the way I achieve it is to always have the first value empty, so it serves as something like a placeholder. However, it'll be great if the plugin has such feature in-built. Almost like the select2 plugin.

  1. So here, I have a list of options
    Screenshot from 2021-09-20 07-32-11

  2. And then, I select one
    Screenshot from 2021-09-20 07-32-30

  3. How do I go back or cancel the selection? My current implementation is to use an empty option. Like the first option in the screenshot below:
    Screenshot from 2021-09-20 07-41-18

  4. And when selected, it looks like a placeholder
    Screenshot from 2021-09-20 07-41-43

  5. However, this would be great to have:

Screenshot from 2021-09-20 07-45-58

@chrisidakwo
Copy link
Author

chrisidakwo commented Sep 20, 2021

I think I should mention that I know there's a .selectpicker('refresh') method. However, this doesn't really work out of the box because one would still have to manually place the icon in the select button and then write an on-click function that deselects the selected option before calling this refresh method to reset the UI. It'll be best if the plugin provided this out-of-the-box.

@NicolasCARPi
Copy link
Collaborator

Can't you use data-showtick=true? On my select it allows to select and unselect by clicking it again. You can see it live here https://demo.elabftw.net/experiments.php in the Tags field on top of screen, middle.

@caseyjhol
Copy link
Member

This is a duplicate of #1449 and is available in v1.14.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants