Skip to content

Commit

Permalink
fix: update details cell visibility when details renderer set (#3352) (
Browse files Browse the repository at this point in the history
…#3353)

Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com>
  • Loading branch information
vaadin-bot and tomivirkki committed Jan 26, 2022
1 parent 348ea74 commit ee17ea7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/grid/src/vaadin-grid-row-details-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export const RowDetailsMixin = (superClass) =>
Array.from(this.$.items.children).forEach((row) => {
if (!row.querySelector('[part~=details-cell]')) {
this._updateRow(row, this._columnTree[this._columnTree.length - 1]);
this._a11yUpdateRowDetailsOpened(row, false);
const isDetailsOpened = this._isDetailsOpened(row._item);
this._a11yUpdateRowDetailsOpened(row, isDetailsOpened);
this._toggleDetailsCell(row, isDetailsOpened);
}
});
}
Expand Down
40 changes: 40 additions & 0 deletions packages/grid/test/row-details.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,44 @@ describe('row details', () => {
expect(countRowsMarkedAsDetailsOpened(grid)).to.equal(0);
});
});

describe('lazily set details renderer', () => {
beforeEach(async () => {
grid = fixtureSync(`
<vaadin-grid>
<vaadin-grid-column path="name"></vaadin-grid-column>
</vaadin-grid>
`);
grid.items = [{ name: 'foo' }];
await nextFrame();
bodyRows = getRows(grid.$.items);
});

it('should have the details cell initially hidden', async () => {
grid.rowDetailsRenderer = () => {};
await nextFrame();
const detailsCell = bodyRows[0].querySelector('[part~="details-cell"]');
expect(detailsCell.hidden).to.be.true;
expect(detailsCell.getAttribute('aria-expanded')).to.equal('false');
});

it('should have the details cell initially visible', async () => {
grid.detailsOpenedItems = [...grid.items];
grid.rowDetailsRenderer = () => {};
await nextFrame();
const detailsCell = bodyRows[0].querySelector('[part~="details-cell"]');
expect(detailsCell.hidden).to.be.false;
expect(detailsCell.getAttribute('aria-expanded')).to.equal('true');
});

it('should have the details cell become visible when details opened', async () => {
grid.rowDetailsRenderer = () => {};
await nextFrame();
grid.detailsOpenedItems = [...grid.items];
await nextFrame();
const detailsCell = bodyRows[0].querySelector('[part~="details-cell"]');
expect(detailsCell.hidden).to.be.false;
expect(detailsCell.getAttribute('aria-expanded')).to.equal('true');
});
});
});

0 comments on commit ee17ea7

Please sign in to comment.