Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: CollectionWrapper remove method doesn't work #32

Closed
ricardo-a-alves-alb opened this issue Dec 6, 2022 · 1 comment
Closed

bug: CollectionWrapper remove method doesn't work #32

ricardo-a-alves-alb opened this issue Dec 6, 2022 · 1 comment

Comments

@ricardo-a-alves-alb
Copy link
Contributor

Hello,

We were trying to use the remove() method available on the CollectionWrapper and it doesn't seem to work.

remove(item) {
if(this.hasItems && item.assignedID) {
for(let i = 0; i < this.wrapper.children.length; i++) {
if(this.wrapper.children[i].assignedID === item.assignedID) {
return this.removeAt(i);
}
}
}
else {
throw new Error('remove: item not found');
}
}

From our investigation, the culprit seems to be the that this.wrapper.children doesn't contain the property assignedID.
Using the internal get items() seems to fix the issue, because it returns the component if it is alive.

get items() {
const itemWrappers = this.itemWrappers;
return this._items.map((item, index) => {
if(itemWrappers[index] && itemWrappers[index].component.isAlive) {
return itemWrappers[index].component;
}
return item;
});
}

If replacing the blocks that use this.wrapper.children with this.items seems good to you, I can provide a PR to be merged.

@jfboeve
Copy link
Contributor

jfboeve commented Dec 20, 2022

Thanks for bringing this to my attention. This is fixed in version 1.3.3

@jfboeve jfboeve closed this as completed Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants