Skip to content

Commit bfed11c

Browse files
authored
fix: check if grid column is attached (#195)
Fixes: vaadin/vaadin-grid#1981 Warranty: Prevent an exception when changing the size after removing columns
1 parent 35b5ff8 commit bfed11c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/vaadin-grid/src/vaadin-grid.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,9 @@ class GridElement extends ElementMixin(
508508
}
509509

510510
if (this._columnTree) {
511-
this._columnTree[this._columnTree.length - 1].forEach((c) => c.notifyPath && c.notifyPath('_cells.*', c._cells));
511+
this._columnTree[this._columnTree.length - 1].forEach(
512+
(c) => c.isConnected && c.notifyPath && c.notifyPath('_cells.*', c._cells)
513+
);
512514
}
513515

514516
beforeNextRender(this, () => {

packages/vaadin-grid/test/column.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,4 +552,13 @@ describe('column', () => {
552552
expect(column._bodyTemplate).to.eql(template2);
553553
});
554554
});
555+
556+
it('should not throw an exception when size is changed after removing column', () => {
557+
expect(grid.size).to.equal(10);
558+
expect(column.isConnected).to.be.true;
559+
column.remove();
560+
expect(column.isConnected).to.be.false;
561+
expect(() => (grid.size = 11)).not.to.throw();
562+
expect(grid.size).to.equal(11);
563+
});
555564
});

0 commit comments

Comments
 (0)