Skip to content

Commit

Permalink
fix: check if grid column is attached (#195)
Browse files Browse the repository at this point in the history
Fixes: vaadin/vaadin-grid#1981
Warranty: Prevent an exception when changing the size after removing columns
  • Loading branch information
tulioag authored Apr 7, 2021
1 parent 35b5ff8 commit bfed11c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/vaadin-grid/src/vaadin-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,9 @@ class GridElement extends ElementMixin(
}

if (this._columnTree) {
this._columnTree[this._columnTree.length - 1].forEach((c) => c.notifyPath && c.notifyPath('_cells.*', c._cells));
this._columnTree[this._columnTree.length - 1].forEach(
(c) => c.isConnected && c.notifyPath && c.notifyPath('_cells.*', c._cells)
);
}

beforeNextRender(this, () => {
Expand Down
9 changes: 9 additions & 0 deletions packages/vaadin-grid/test/column.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,4 +552,13 @@ describe('column', () => {
expect(column._bodyTemplate).to.eql(template2);
});
});

it('should not throw an exception when size is changed after removing column', () => {
expect(grid.size).to.equal(10);
expect(column.isConnected).to.be.true;
column.remove();
expect(column.isConnected).to.be.false;
expect(() => (grid.size = 11)).not.to.throw();
expect(grid.size).to.equal(11);
});
});

0 comments on commit bfed11c

Please sign in to comment.