ui-select icon indicating copy to clipboard operation
ui-select copied to clipboard

onSelect and onRemove don't trigger

Open DarkIsDude opened this issue 7 years ago • 6 comments

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

DarkIsDude avatar Jul 18 '17 09:07 DarkIsDude

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

ThibaultChauvidan avatar Jul 25 '17 07:07 ThibaultChauvidan

Thanks for your help. You are right, it seem that just onRemove has issue. I will try a PR maybe :).

DarkIsDude avatar Jul 26 '17 09:07 DarkIsDude

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?

Jefiozie avatar Aug 14 '17 05:08 Jefiozie

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

DarkIsDude avatar Sep 06 '17 08:09 DarkIsDude

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!

augustjared1 avatar Feb 21 '18 20:02 augustjared1

+1

ganholete avatar Feb 28 '19 21:02 ganholete