lekoala/bootstrap5-tags

Possibility to add same tag multiple times

halali opened this issue · 12 comments

Hi,

i would like to have setting to enable possibility to add one tag more times

@halali that is going to be really difficult since this is based on a select element that doesn't allow same values multiple times

if I decouple the script for the select tag, then it becomes possible

maybe there should be small hack... on select item it will add same item to select element and remove one on clear

is that solution possible ?

@halali actually, you can use the same value in a select (surprisingly!)
I pushed on master some changes to allow this and updated the demo accordingly

can you give it a try?

@lekoala damn you are fast, thanks work as expected...

Will do more test next week...

just an question... will be possible add custom event for select tag and clear tag so i can run function when tag is selected and another when tag is cleared from select.

Found bug.

When i add 3 same tags
i have in list 3 same values in selected list -> this is expected

and after i remove all one by one
only first removed tag is removed from list. so i dont see any tags in select input but in tags._selectElement.querySelectorAll("option[selected]") i have 2 items

@halali indeed, should be fixed on master now

@lekoala i can confirm. work now

what about event for select, remove tag ?
should i open another FR or is not planed ?

of course i can handle it by change event, but i need to compare arrays what was added or removed.

@halali there is already a onSelectItem(item) callback
I just added the onClearItem(value) as well on master

if you see anything else let me know

Thank you.

I will close this as resolved.

Hello again, onClearItem event dont work if you use backspace to clear item and not X

Thanks, work perfectly