buttonwoodcx / bcx-aurelia-reorderable-repeat

An Aurelia repeater supports drag & drop reordering automatically.
https://buttonwoodcx.github.io/doc-bcx-aurelia-dnd/reorderable-repeat
MIT License
19 stars 5 forks source link

fix(reorderable-group-map): check for null items #22

Closed MaximBalaganskiy closed 3 years ago

MaximBalaganskiy commented 3 years ago

This crashes if an element with the repeater is hidden and at the same time the items is changed. unbind sets items to null before the task queue calls repeater.add.

3cp commented 3 years ago

Thx. Can you share a demo maybe in gist.dumber.app? I want to understand the nature of this bug.

MaximBalaganskiy commented 3 years ago

Observe the dev tools console https://gist.dumber.app/?gist=e94702c2adda89af612d35f28374b841

3cp commented 3 years ago

Thx. I will test more. Probably this.groupMap.remove(this); has a memory leak since items is null after queueMicroTask.

MaximBalaganskiy commented 3 years ago

As far as I can tell, this is due to async task working. Nothing should happen in queueTask after unbind worked

3cp commented 3 years ago

v1.4.1 is released to fix the issue.

That async logic is wrongly triggered after the repeat is unbound, that's where the items became null. The logic is designed to refresh dnd registration during the life time of the repeater, it's irrelevant after repeat is unbound.