Skip to content

Commit

Permalink
fix: only run the crud grid header renderer once (#3386)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki committed Feb 3, 2022
1 parent 2570682 commit 158f36a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/crud/src/vaadin-crud-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ class CrudGrid extends IncludedMixin(Grid) {
if (!this.noHead && path) {
// Create a header renderer for the column (or column group)
col.headerRenderer = (root) => {
if (root.firstElementChild) {
return;
}

const label = this._generateHeader(path);

if (col.__sortColumnGroup || (this.noFilter && !this.noSort)) {
Expand Down
7 changes: 7 additions & 0 deletions packages/crud/test/crud-grid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ describe('crud grid', () => {
it('should capitalize correctly', () => {
expect(grid.__capitalize('aa.bb cc-dd FF')).to.be.equal('Aa bb cc dd ff');
});

it('should only render one control in a cell', async () => {
grid.requestContentUpdate();
await nextRender(grid);
expect(getHeaderCellContent(grid, 1, 0).childElementCount).to.equal(1);
expect(getHeaderCellContent(grid, 2, 0).childElementCount).to.equal(1);
});
});
});
});
Expand Down

0 comments on commit 158f36a

Please sign in to comment.