Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not set aria-expanded on grid cells #3441

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions packages/grid/src/vaadin-grid-a11y-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,6 @@ export const A11yMixin = (superClass) =>
row.setAttribute('aria-level', level + 1);
}

/**
* @param {!HTMLElement} row
* @param {boolean} detailsOpened
* @protected
*/
_a11yUpdateRowDetailsOpened(row, detailsOpened) {
const detailsCell = row.querySelector('[part~=details-cell]');

Array.from(row.children).forEach((cell) => {
if (detailsCell) {
cell.setAttribute('aria-expanded', detailsOpened);
} else {
cell.removeAttribute('aria-expanded');
}
});
}

/**
* @param {!HTMLElement} row
* @param {!HTMLElement} detailsCell
Expand Down
1 change: 0 additions & 1 deletion packages/grid/src/vaadin-grid-row-details-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export const RowDetailsMixin = (superClass) =>
if (!row.querySelector('[part~=details-cell]')) {
this._updateRow(row, this._columnTree[this._columnTree.length - 1]);
const isDetailsOpened = this._isDetailsOpened(row._item);
this._a11yUpdateRowDetailsOpened(row, isDetailsOpened);
this._toggleDetailsCell(row, isDetailsOpened);
}
});
Expand Down
1 change: 0 additions & 1 deletion packages/grid/src/vaadin-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,6 @@ class Grid extends ElementMixin(

this._a11yUpdateRowLevel(row, model.level);
this._a11yUpdateRowSelected(row, model.selected);
this._a11yUpdateRowDetailsOpened(row, model.detailsOpened);

row.toggleAttribute('expanded', model.expanded);
row.toggleAttribute('selected', model.selected);
Expand Down
25 changes: 0 additions & 25 deletions packages/grid/test/accessibility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@ describe('accessibility', () => {
});

describe('row details not in use', () => {
it('should not have aria-expanded on body cells', () => {
expect(uniqueAttrValues(grid.$.items.querySelectorAll('td'), 'aria-expanded')).to.eql([null]);
});

it('should not have aria-controls on body cells', () => {
expect(uniqueAttrValues(grid.$.items.querySelectorAll('td'), 'aria-controls')).to.eql([null]);
});
Expand Down Expand Up @@ -259,10 +255,6 @@ describe('accessibility', () => {
});

describe('row details in use', () => {
it('should have aria-expanded false on body cells', () => {
expect(uniqueAttrValues(grid.$.items.querySelectorAll('td'), 'aria-expanded')).to.eql(['false']);
});

it('should have aria-controls referencing detail cell id on body cells', () => {
Array.from(grid.$.items.children).forEach((row) => {
const detailsCell = row.querySelector('td[part~="details-cell"]');
Expand All @@ -274,23 +266,6 @@ describe('accessibility', () => {
]);
});
});

it('should set aria-expanded true on cells after row details opened', () => {
grid.openItemDetails(grid.items[0]);

expect(uniqueAttrValues(grid.$.items.children[0].children, 'aria-expanded')).to.eql(['true']);

expect(uniqueAttrValues(grid.$.items.children[1].children, 'aria-expanded')).to.eql(['false']);
});

it('should set aria-expanded false on cells after row details closed', () => {
grid.openItemDetails(grid.items[0]);
grid.closeItemDetails(grid.items[0]);

expect(uniqueAttrValues(grid.$.items.children[0].children, 'aria-expanded')).to.eql(['false']);

expect(uniqueAttrValues(grid.$.items.children[1].children, 'aria-expanded')).to.eql(['false']);
});
});
});

Expand Down
3 changes: 0 additions & 3 deletions packages/grid/test/row-details.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ describe('row details', () => {
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 () => {
Expand All @@ -412,7 +411,6 @@ describe('row details', () => {
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 () => {
Expand All @@ -422,7 +420,6 @@ describe('row details', () => {
await nextFrame();
const detailsCell = bodyRows[0].querySelector('[part~="details-cell"]');
expect(detailsCell.hidden).to.be.false;
expect(detailsCell.getAttribute('aria-expanded')).to.equal('true');
});
});
});