Skip to content

Commit

Permalink
fix: details broken when hidden (#1754)
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-g authored Jun 14, 2020
1 parent 8e04f03 commit 7eabb73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vaadin-grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@
}
columns
.filter(column => !column.hidden)
.forEach((column, index) => {
.forEach((column, index, cols) => {
let cell;

if (section === 'body') {
Expand All @@ -593,7 +593,7 @@
cell.setAttribute('part', 'cell body-cell');
row.appendChild(cell);

if (index === columns.length - 1 && (this._rowDetailsTemplate || this.rowDetailsRenderer)) {
if (index === cols.length - 1 && (this._rowDetailsTemplate || this.rowDetailsRenderer)) {
// Add details cell as last cell to body rows
this._detailsCells = this._detailsCells || [];
const detailsCell = this._detailsCells.filter(cell => cell._vacant)[0] || this._createCell('td');
Expand Down
9 changes: 9 additions & 0 deletions test/column.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@
flushGrid(grid);
expect(() => grid.render()).not.to.throw(Error);
});

it('should not remove details row when a column is hidden', () => {
grid.rowDetailsRenderer = root => root.textContent = 'row-details';
grid.detailsOpenedItems = [grid._cache.items[0]];
column.hidden = true;
flushGrid(grid);
const details = grid.shadowRoot.querySelector('#items [part~="details-cell"]')._content;
expect(details.textContent).to.equal('row-details');
});
});

describe('path', () => {
Expand Down

0 comments on commit 7eabb73

Please sign in to comment.