Skip to content

Commit 3f0b125

Browse files
author
Kubit
committed
Improve accesibility properties on Tables components
1 parent 3befe5e commit 3f0b125

File tree

9 files changed

+56
-20
lines changed

9 files changed

+56
-20
lines changed

src/components/dataTable/__tests__/hooks/useDataTableStickyRightColumns.test.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,6 @@ describe('useDataTableStickyRightColumns', () => {
1313
let rightBoxShadowContainer: HTMLDivElement;
1414
let ref: React.RefObject<HTMLDivElement>;
1515

16-
beforeAll(() => {
17-
global.ResizeObserver = class ResizeObserver {
18-
callback;
19-
constructor(callback) {
20-
this.callback = callback;
21-
}
22-
observe() {
23-
// Call the callback
24-
this.callback();
25-
}
26-
unobserve() {
27-
// do nothing
28-
}
29-
disconnect() {
30-
// do nothing
31-
}
32-
};
33-
});
34-
3516
beforeEach(() => {
3617
wrapper = document.createElement('div');
3718
scrollableContainer = document.createElement('div');

src/components/dataTable/dataTableStandAlone.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const DataTableStandAloneComponent = (
4747
tabIndex={hasScroll ? 0 : undefined}
4848
>
4949
<TableV2
50+
aria-hidden={usingRowGroups ? true : undefined}
5051
autoLeftStickyCalc={false}
5152
autoRightStickyCalc={false}
5253
component={usingRowGroups ? 'div' : undefined}

src/components/table/stories/mockCustomizable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const mockCustomizableTable = {
4141
<div>{value.surname}</div>
4242
</div>
4343
) : (
44-
(value.name.value ?? value.name)
44+
value.name.value ?? value.name
4545
),
4646
},
4747
{

src/components/tableRow/stories/argtypes.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,28 @@ export const argtypes = (
7272
category: CATEGORY_CONTROL.CUSTOMIZATION,
7373
},
7474
},
75+
role: {
76+
description: 'Role',
77+
type: { name: 'string' },
78+
control: { type: 'text' },
79+
table: {
80+
type: {
81+
summary: 'string',
82+
},
83+
category: CATEGORY_CONTROL.ACCESIBILITY,
84+
},
85+
},
86+
tabIndex: {
87+
description: 'Tab index',
88+
type: { name: 'number' },
89+
control: { type: 'number' },
90+
table: {
91+
type: {
92+
summary: 'number',
93+
},
94+
category: CATEGORY_CONTROL.ACCESIBILITY,
95+
},
96+
},
7597
onClick: {
7698
description: 'Click event',
7799
type: { name: 'function' },
@@ -82,6 +104,16 @@ export const argtypes = (
82104
category: CATEGORY_CONTROL.FUNCTIONS,
83105
},
84106
},
107+
onKeyDown: {
108+
description: 'Key down event',
109+
type: { name: 'function' },
110+
table: {
111+
type: {
112+
summary: 'React.KeyboardEventHandler<HTMLTableRowElement>',
113+
},
114+
category: CATEGORY_CONTROL.FUNCTIONS,
115+
},
116+
},
85117
onMouseEnter: {
86118
description: 'Mouse enter event',
87119
type: { name: 'function' },

src/components/tableRow/tableRowStandAlone.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ const TableRowStandAloneComponent = (
1111
id,
1212
active,
1313
hoverable = true,
14+
role,
15+
tabIndex,
1416
component,
1517
onClick,
18+
onKeyDown,
1619
onMouseEnter,
1720
onMouseLeave,
1821
}: React.PropsWithChildren<ITableRowStandAlone>,
@@ -29,7 +32,10 @@ const TableRowStandAloneComponent = (
2932
data-hoverable={hoverable}
3033
data-testid={dataTestId}
3134
id={id}
35+
role={role}
36+
tabIndex={tabIndex}
3237
onClick={onClick}
38+
onKeyDown={onKeyDown}
3339
onMouseEnter={onMouseEnter}
3440
onMouseLeave={onMouseLeave}
3541
>

src/components/tableRow/types/tableRow.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ export interface ITableRowStandAlone {
77
id?: string;
88
active?: boolean;
99
hoverable?: boolean;
10+
role?: string;
11+
tabIndex?: number;
1012
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1113
component?: string | React.ComponentType<any>;
1214
dataTestId?: string;
1315
onClick?: React.MouseEventHandler<HTMLTableRowElement>;
16+
onKeyDown?: React.KeyboardEventHandler<HTMLTableRowElement>;
1417
onMouseEnter?: React.MouseEventHandler<HTMLTableRowElement>;
1518
onMouseLeave?: React.MouseEventHandler<HTMLTableRowElement>;
1619
}

src/components/tableV2/stories/argtypes.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ export const argtypes = (
6868
category: CATEGORY_CONTROL.CUSTOMIZATION,
6969
},
7070
},
71+
['aria-hidden']: {
72+
description: 'Aria hidden',
73+
type: { name: 'boolean' },
74+
control: { type: 'boolean' },
75+
table: {
76+
type: {
77+
summary: 'boolean',
78+
},
79+
category: CATEGORY_CONTROL.ACCESIBILITY,
80+
},
81+
},
7182
['aria-label']: {
7283
description: 'Only when it has scroll, scrollable container aria label',
7384
type: { name: 'string' },

src/components/tableV2/tableStandAlone.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const TableStandAloneComponent = (
3636
data-table-scrollable-container
3737
$hasScrollDisabled={hasScrollDisabled}
3838
$styles={styles}
39+
aria-hidden={props['aria-hidden']}
3940
aria-label={hasScroll ? props['aria-label'] : undefined}
4041
aria-labelledby={hasScroll ? props['aria-labelledby'] : undefined}
4142
data-testid={`${dataTestId}ScrollableContainer`}

src/components/tableV2/types/table.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { CustomTokenTypes } from '@/types';
33
import { TablePropsStylesTypeV2 } from './tableTheme';
44

55
type TableScrollAriasType = {
6+
['aria-hidden']?: boolean;
67
['aria-label']?: string;
78
['aria-labelledby']?: string;
89
};

0 commit comments

Comments
 (0)