isteven / angular-multi-select

A multi select dropdown directive for AngularJS. Allows you to use HTML tags and CSS in the data. Requires only AngularJS and nothing else.
isteven.github.io/angular-multi-select
MIT License
1.08k stars 518 forks source link

"none" helper does not show up when using `selection-mode="single"` #533

Open dailytabs opened 7 years ago

dailytabs commented 7 years ago

When in single selection mode, using helper-elements="none filter" the "Select None" button does not show up (the search filter does show up). This prevents the user from being able to go back to having nothing selected, without me intervening with logic of my own and another UI element.

ladaltamirano commented 6 years ago

+1 Yeah!.., I would need this too... Do you think it is too difficult to implement @isteven ? If you guide me guys I could implement and push it. Thanks!

isteven commented 6 years ago

Hi @Acaspita ,

The single selection mode intends to mimic the usual HTML dropdown. Hence you cannot "unselect" a selection. What you can do is to add an extra row into your input-model like:

var inputData = [ 
    { title: '[Please select an item]', value: 0, ticked: true }, 
    { title: 'Item 1', value: 1, ticked: false }, 
    { title: 'Item 2', value: 2, ticked: false }, 
    ...
];

And validate before you save your form that, if "[Please select an item]" is selected, it doesn't count (or it's not part of the data).

Edit: it shouldn't be too hard to implement, but unfortunately I won't be able to guide you as I'm quite occupied with a lot of stuffs.