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

Remove item: Cannot read property 'hasAttribute' of null #279

Closed
AndrewK15 opened this issue Mar 22, 2018 · 2 comments
Closed

Remove item: Cannot read property 'hasAttribute' of null #279

AndrewK15 opened this issue Mar 22, 2018 · 2 comments
Labels

Comments

@AndrewK15
Copy link

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?

@tiberiuzuld
Copy link
Owner

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.

@tiberiuzuld
Copy link
Owner

The fix will be available in version 5.0.0 coming soon.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants