Skip to content

Commit 8b497e9

Browse files
PivotGrid - Add role="button" to expandable cells
1 parent f375658 commit 8b497e9

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

packages/devextreme/js/__internal/grids/pivot_grid/area_item/m_area_item.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ abstract class AreaItem {
198198
span.classList.add(PIVOTGRID_EXPAND_CLASS);
199199
div.appendChild(span);
200200
td.appendChild(div);
201+
td.setAttribute('role', 'button');
201202
td.setAttribute('aria-expanded', String(cell.expanded));
202203
td.setAttribute('tabindex', '0');
203204
}

packages/devextreme/testing/tests/DevExpress.ui.widgets.pivotGrid/pivotGrid.markup.tests.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,27 @@ QUnit.module('PivotGrid markup tests', () => {
142142
}
143143
});
144144

145-
QUnit.test('Non-expandable td has neither aria-expanded nor tabindex', function(assert) {
145+
QUnit.test('Expandable td has role="button"', function(assert) {
146+
if(!windowUtils.hasWindow()) {
147+
assert.ok(true, 'skipped on serverSide');
148+
return;
149+
}
150+
const clock = sinon.useFakeTimers();
151+
try {
152+
const pivotGrid = createPivotGrid({ dataSource: createExpandableDataSource() });
153+
clock.tick(10);
154+
155+
const $expandedTd = pivotGrid.$element().find('.dx-pivotgrid-expanded').first().closest('td');
156+
const $collapsedTd = pivotGrid.$element().find('.dx-pivotgrid-collapsed').first().closest('td');
157+
158+
assert.strictEqual($expandedTd.attr('role'), 'button', 'expanded td has role="button"');
159+
assert.strictEqual($collapsedTd.attr('role'), 'button', 'collapsed td has role="button"');
160+
} finally {
161+
clock.restore();
162+
}
163+
});
164+
165+
QUnit.test('Non-expandable td has no role, aria-expanded, or tabindex', function(assert) {
146166
if(!windowUtils.hasWindow()) {
147167
assert.ok(true, 'skipped on serverSide');
148168
return;
@@ -155,6 +175,7 @@ QUnit.module('PivotGrid markup tests', () => {
155175
const $nonExpandableTd = pivotGrid.$element().find('td:not([aria-expanded])').first();
156176

157177
assert.ok($nonExpandableTd.length > 0, 'non-expandable td exists');
178+
assert.strictEqual($nonExpandableTd.attr('role'), undefined, 'no role attribute');
158179
assert.strictEqual($nonExpandableTd.attr('aria-expanded'), undefined, 'no aria-expanded attribute');
159180
assert.strictEqual($nonExpandableTd.attr('tabindex'), undefined, 'no tabindex attribute');
160181
} finally {

0 commit comments

Comments
 (0)