Skip to content

Commit 1b32068

Browse files
authored
PivotGrid - A11y - Make field chooser button have visible focus state (#33942)
1 parent 895f31f commit 1b32068

6 files changed

Lines changed: 46 additions & 11 deletions

File tree

19.9 KB
Loading
10.1 KB
Loading
19.9 KB
Loading
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
2+
import PivotGrid from 'devextreme-testcafe-models/pivotGrid';
3+
import { testScreenshot } from '../../../../helpers/themeUtils';
4+
import url from '../../../../helpers/getPageUrl';
5+
import { createWidget } from '../../../../helpers/createWidget';
6+
7+
fixture.disablePageReloads`PivotGrid_KBN_fieldChooser`
8+
.page(url(__dirname, '../../../container.html'));
9+
10+
const PIVOT_GRID_SELECTOR = '#container';
11+
[
12+
['filter-fields', { visible: true, showFilterFields: true }],
13+
['column-fields', { visible: true, showDataFields: true }],
14+
['description-cell', { visible: false }],
15+
].forEach(([areaName, fieldPanelOptions]) => {
16+
test(`Field chooser button should have visible focus state when placed in ${areaName}`, async (t) => {
17+
const pivotGrid = new PivotGrid(PIVOT_GRID_SELECTOR);
18+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
19+
20+
await t
21+
.pressKey('tab')
22+
.expect(pivotGrid.getFieldChooserButton().focused)
23+
.ok();
24+
25+
await testScreenshot(t, takeScreenshot, `field-chooser-button_focus_${areaName}.png`);
26+
27+
await t
28+
.expect(compareResults.isValid())
29+
.ok(compareResults.errorMessages());
30+
}).before(async () => createWidget('dxPivotGrid', {
31+
allowFiltering: true,
32+
showBorders: true,
33+
height: 470,
34+
fieldChooser: {
35+
enabled: true,
36+
},
37+
fieldPanel: fieldPanelOptions,
38+
}, PIVOT_GRID_SELECTOR));
39+
});

packages/devextreme-scss/scss/widgets/base/pivotGrid/_index.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,6 @@ $pivotgrid-expand-icon-text-offset: 0;
222222
.dx-button {
223223
margin: 1px;
224224
}
225-
226-
.dx-button:not(.dx-state-hover):not(.dx-state-active) {
227-
border-color: transparent;
228-
background-color: transparent;
229-
box-shadow: none;
230-
}
231225
}
232226
}
233227

packages/devextreme/js/__internal/grids/pivot_grid/m_widget.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import {
1616
import { format as formatString } from '@js/core/utils/string';
1717
import { isDefined } from '@js/core/utils/type';
1818
import { getWindow, hasWindow } from '@js/core/utils/window';
19-
import type { Properties } from '@js/ui/button';
19+
import type { ButtonStyle, Properties } from '@js/ui/button';
2020
import Button from '@js/ui/button';
2121
import ContextMenu from '@js/ui/context_menu';
2222
import Popup from '@js/ui/popup/ui.popup';
23-
import { current, isFluent } from '@js/ui/themes';
23+
import { current, isGeneric } from '@js/ui/themes';
2424
import Widget from '@ts/core/widget/widget';
2525
import gridCoreUtils from '@ts/grids/grid_core/m_utils';
2626

@@ -945,6 +945,8 @@ class PivotGrid extends Widget {
945945

946946
let $targetContainer;
947947

948+
let buttonStylingMode: ButtonStyle = isGeneric(current()) ? 'contained' : 'text';
949+
948950
// @ts-expect-error ts-error
949951
if (fieldPanel.visible && fieldPanel.showFilterFields) {
950952
$targetContainer = $filterHeader;
@@ -953,6 +955,7 @@ class PivotGrid extends Widget {
953955
$targetContainer = $columnHeader;
954956
} else {
955957
$targetContainer = $descriptionCell;
958+
buttonStylingMode = 'text';
956959
}
957960

958961
$columnHeader.toggleClass(
@@ -976,7 +979,6 @@ class PivotGrid extends Widget {
976979
this.$element().find('.dx-pivotgrid-toolbar').remove();
977980

978981
$toolbarContainer.prependTo($targetContainer);
979-
const stylingMode = isFluent(current()) ? 'text' : 'contained';
980982

981983
if (this.option('fieldChooser.enabled')) {
982984
const $buttonElement = $(DIV)
@@ -986,7 +988,7 @@ class PivotGrid extends Widget {
986988
icon: 'columnchooser',
987989
// @ts-expect-error ts-error
988990
hint: this.option('texts.showFieldChooser'),
989-
stylingMode,
991+
stylingMode: buttonStylingMode,
990992
onClick: () => {
991993
this.getFieldChooserPopup().show();
992994
},
@@ -1003,7 +1005,7 @@ class PivotGrid extends Widget {
10031005
icon: 'xlsxfile',
10041006
// @ts-expect-error ts-error
10051007
hint: this.option('texts.exportToExcel'),
1006-
stylingMode,
1008+
stylingMode: buttonStylingMode,
10071009
onClick: () => {
10081010
// @ts-expect-error ts-error
10091011
this.exportTo();

0 commit comments

Comments
 (0)