ui-select
ui-select copied to clipboard
onSelect and onRemove don't trigger
Bug description:
on-remove and on-select never trigger
Link to minimally-working plunker that reproduces the issue:
http://plnkr.co/edit/CtSiLw60WnfcNL0h4cqp?p=preview [edit 06/09/2017] With multiple example http://plnkr.co/edit/V2cVQojYpZACNrMUaaRC?p=preview
Version of Angular, UI-Select, and Bootstrap/Select2/Selectize CSS
Angular: 1.5.0
UI-Select: 0.19.8
Bootstrap/Select2/Selectize CSS (if applicable): See in plunker
Actually only onRemove has issue, I modify the plnkr and onSelect work fine. It's just you can't use console log in the HTML code. I also add ngChange and onChange, it's seem that ngChange work fine but not onChange Hope it helped
Thanks for your help. You are right, it seem that just onRemove has issue. I will try a PR maybe :).
Thanks for the PR. I think this needs some extra digging, when using the onRemove
with the multiple it is working. So it look like a specific single select
problem. Also is the onRemove
not working in general or is it just with the combination of allow-clear
?
How can I remove an element without the allow-clear directive in single mode? I have updated the plnkr for add multiple example. You are right, with the multiple attribute, onRemove work.
http://plnkr.co/edit/V2cVQojYpZACNrMUaaRC?p=preview
I have a fix!!! My coworker found it based on our old code! the ctrl.clear (line 541 in select.js) function should read like below
ctrl.clear = function ($event) { var itemRemove = ctrl.selected; ctrl.select(undefined); $event.stopPropagation(); ctrl.focusser[0].focus(); ctrl.onRemoveCallback($scope, { $item: itemRemove }); }; The bolded lines are missing after the update and when I put them back in -- it worked just fine. Hope this helps!
+1