angular-multi-select icon indicating copy to clipboard operation
angular-multi-select copied to clipboard

Triggering multiple on-item-click events

Open kovachev opened this issue 11 years ago • 10 comments

I have an array of items that have sub-items, once an item is marked (checked) in the multi-select control a new multi-select controls should render bellow the main (parent) one for each of the marked sub-items.

Everything is almost working out of the box except that the first (parent) multi-select control is triggering multiple on-item-click events and has some kinky UI behavior. I suppose this is related to the DOM been changed by angular repeater that creates the multi-selects for sub-items.

Here is a sample plunker: http://plnkr.co/edit/zacUbpBMsGh203VvwfJb?p=preview

kovachev avatar Dec 04 '14 14:12 kovachev

Hi @kovachev ,

Yes I saw that. Unfortunately I'm not sure I have a solution.. at least not now. Been very busy recently.

If you can help with a fix - and I would very much appreciate that :) - the on-item-click is triggered by a $watch. Open the directive code line 838 and you can see it there.

Also, can you help to describe the kinky UI behaviours? I couldn't really see it from your example.

isteven avatar Dec 05 '14 01:12 isteven

Hi @isteven,

I also don't have a fix for the issue, however I've a simple workaround that fits in my use case. Just added a scope flag to monitor when multi-select is opened and while it is opened the filter function returns the previous marked state, thus preventing DOM changes. Here is the plunker (it might help someone else): http://plnkr.co/edit/sByil7d0rq5dXczUmuSE?p=preview

The kinky UI behavior is related to the issue - just some hover/active styles persist after you mark an item and everything goes back to normal once the pointer leaves the item. This is happening in Chrome, here is a screenshot:

screenshot 2014-12-05 09 43 08

kovachev avatar Dec 05 '14 08:12 kovachev

I noticed a similar problem causing a worse outcome, namely one click will cause an item to be selected then unselected (if the item was first unselected and vice versa if the item was selected) making it impossible to select anything other than the initial selection. I noticed this by adding an on-item-click attribute to the element that logged the event to the console. I am using version 2.0.2

I am not sure if this post belongs here, though. I do not have sub-items. If I should open another issue, let me know.

c1moore avatar Dec 18 '14 03:12 c1moore

hi @c1moore ,

For the kinky UI behaviour.. I suspect it's related to the dynamic behaviour of the multi-selects (as in the way it is triggered).

Can you please duplicate the problem on Plunker / Fiddler? Thanks.

isteven avatar Dec 18 '14 04:12 isteven

I have been unable to duplicate the issue so far, oddly. Most of the code is duplicated and I am importing most of the libraries in use. Are there any known issues with snap.js or angular-snap.js? I am still trying to duplicate the problem though.

By the way, I am not noticing the kinky UI behavior, just multiple triggers for on-item-click causing an item to be selected then immediately unselected.

c1moore avatar Dec 18 '14 16:12 c1moore

Oddly enough I am not able to duplicate the issue with all of my code duplicated in Plunker and all libraries imported...

c1moore avatar Dec 18 '14 17:12 c1moore

The problem appears to be with an extension for Chrome (AngularJS Batarang). Turning it off fixes the problem and turning it back on breaks the multi-selects.

c1moore avatar Dec 18 '14 20:12 c1moore

Hi @c1moore ,

A user recently also reported a problem with Angular Batarang: https://github.com/isteven/angular-multi-select/issues/150

I'm really confused.. Can any Batarang users explain why?

isteven avatar Dec 19 '14 01:12 isteven

@isteven it's not only this directive problem. It was working fine with Batarang before Batarang's update. Take a look here: https://chrome.google.com/webstore/detail/angularjs-batarang/ighdmehidhipcmcojjgiloacoafjmpfk/reviews

ktopolski avatar Dec 21 '14 23:12 ktopolski

I have decided just not to use Batarang for now. It wasn't awfully useful to me anyways after the changes everybody seems to be complaining about in the link @ktopolski gave.

c1moore avatar Dec 21 '14 23:12 c1moore