'Cannot redraw item: no parent attached' if cluster exists when nested groups are expanded
If clusters would be drawn when expanding a nested group, it throws the following error:
Error:
ClusterItem.js:462 Uncaught Error: Cannot redraw item: no parent attached
at e.value (ClusterItem.js:462)
at Group.js:1110
at Object.forEach (esm.js:5481)
at t.value (Group.js:1109)
at t.value (Group.js:403)
at Array.<anonymous> (Group.js:517)
at ItemSet.js:840
at Object.forEach (esm.js:5481)
at i (ItemSet.js:839)
at ItemSet.js:838
The error only occurs if the clusters would exist on expanding the group. In other projects, if you're zoomed in and no clusters would be made, expand the group, then zoom out, no errors happen.
Example (based off official docs for nested groups): (open dev tools and attempt to expand a group): https://jsbin.com/qucozujemu/2
I subscribed to this thread, just wondering if there is any update on this issue. I too am experiencing this.
+1
Still an issue :"(
Hey guys, I encountered this problem as well.
Here is my workaround which seems to be working for my problem. Maybe you can use it as well.
I was programmatically collapsing and uncollapsing the groups:
(from the click handler I was able to get which group was clicked and thus the subgroupId)
const subgroup = timelineGroups.get(subgroupId);
timelineGroups.update({ id: subgroupId, visible: !subgroup.visible });
This resulted in the same error as when I made my groups visible again, the clustered items triggered this error.
So I disabled and then reenabled the clustering after updating the groups with the
timeline.setOptions function
So the final code should look like something like this:
I use the react version of the timeline, so that's why there is a timelineRef in the code. Don't forget the reenable your original clustering rules, if there was one.
timelineRef.current.timeline.setOptions({ cluster: {
titleTemplate: undefined,
clusterCriteria: () => false,
} });
const subgroup = timelineGroups.get(subgroupId);
timelineGroups.update({ id: subgroupId, visible: !subgroup.visible });
timelineRef.current.timeline.setOptions({ cluster: {
titleTemplate: undefined,
clusterCriteria: () => true,
} });
I had this issue recently. I fixed it by doing the following:
this.timeline.on('click', (properties) => {
switch (properties.what) {
case 'group-label': {
let group = this.groups.get(properties.group)
if (group && group.showNested == false) {
this.timeline.itemSet.clusterGenerator.updateData()
}
break
}
}
})
The problem I had was that upon closing a group (with nested subgroups), the timeline would not render correctly.