Hello, I encountered an error when modifying array of grid items. I remove an item on button click:
remove(item: GridsterItem, row: DashboardGridRow) {
row.items = row.items.filter(rowItem => rowItem !== item);
}
<div class="row" *ngFor="let row of dashboard.rows">
<div class="col">
<gridster class="dashboard-row-grid" [options]="options">
<gridster-item #itemComponent class="dashboard-grid-item" [item]="item"
*ngFor="let item of row.items">
<button type="button" class="btn btn-warning" (click)="remove(item, row)">
Remove
</button>
</gridster-item>
</gridster>
</div>
</div>
When I click the button, item gets removed, but I always get an error in the console:
ERROR TypeError: Cannot read property 'hasAttribute' of null
at Function.GridsterUtils.checkContentClass (gridsterUtils.service.js:65)
at Function.GridsterUtils.checkContentClass (gridsterUtils.service.js:69)
at Function.GridsterUtils.checkContentClass (gridsterUtils.service.js:69)
at Function.GridsterUtils.checkContentClassForEmptyCellClickEvent (gridsterUtils.service.js:58)
at GridsterEmptyCell.emptyCellClickCb (gridsterEmptyCell.service.js:59)
at HTMLUnknownElement.eval (platform-browser.js:2628)
at ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4740)
at ZoneDelegate.invokeTask (zone.js:420)
at Zone.runTask (zone.js:188)
Any ideas? Should I do something extra?
Yeah do stop event propagation, it checks for drag and you removed the element ...
Maybe should add a check in the code also.
But for now add a stopEventPropagation and should work.
The fix will be available in version 5.0.0 coming soon.
Thanks
Most helpful comment
Yeah do stop event propagation, it checks for drag and you removed the element ...
Maybe should add a check in the code also.
But for now add a stopEventPropagation and should work.