jaumard / ngx-dashboard

Dashboard library for angular 4 and more
https://jaumard.github.io/ngx-dashboard/demo/demoDist/index.html
MIT License
71 stars 31 forks source link

Issue with deleting custom widgets #11

Closed nadir35 closed 7 years ago

nadir35 commented 7 years ago

After creating several custom widgets and trying to close them with dashboard.removeById(), a bug occurs if you shuffle the widgets order. It looks like the wrong widget is getting removed, however upon inspection of the "elements" array of the DashboardComponent I can see that the widget with the correct ID was removed. I also noticed that "disableAnimation" seems to fail in this scenario, the element of the widget I was trying to delete remains with "animate" and pretty much breaks. Is such a problem known to you? Have you tried to do removable custom widgets? Maybe my implementation of that is just wrong. I can upload my project so you can see for yourself if you want.

jaumard commented 7 years ago

Hi @nadir35 I'm using custom widgets on my project L.I.S.A. with the ability to remove a custom widget but I didn't notice any problem with it. Take a look at it https://github.com/mylisabox/lisa-ui but if you didn't find a solution yes please make a small project, like this I can try and see the problem Thanks

nadir35 commented 7 years ago

Hi, thanks for the quick response.

I have looked into your project, and adapted the way you handle the onRemoveEvent. However the problem still remains... I have uploaded my project here : https://github.com/nadir35/customwidgetdashboard/tree/master/testa

To reproduce add 2 widgets to the dashboard, then swap their order and then try to delete either. Thanks.

jaumard commented 7 years ago

Thanks for the project ! I was able to find where the problem come from... The problem is here https://github.com/jaumard/ngx-dashboard/blob/master/src/components/dashboard/dashboard.component.ts#L210 when you reorder widgets the order of _viewCntRef is not changed so it remove the wrong one :(

For now I don't know how to fix it, any idea? I'll keep searching

jaumard commented 7 years ago

Fixed on v1.1.0 by an ugly fix for now, if I found a better way I'll change that. Also be careful I change the name of the module to NgDashboardModule as I leave angular 2 behind

nadir35 commented 7 years ago

Thank you.