Skip to content
Open
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
4 changes: 4 additions & 0 deletions src/components/Table/Internal/OcTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,10 @@ function OcTable<RecordType extends DefaultRecordType>(
styles.tableContainer,
{ [styles.tableContainerHorizontallyScrollable]: horizontalScroll },
])}
{...(horizontalScroll && {
role: 'region',
tabIndex: 0,
})}
>
{groupTableNode}
</div>
Expand Down
40 changes: 40 additions & 0 deletions src/components/Table/Internal/Tests/Scroll.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,46 @@ describe('Table.Scroll', () => {
expect(wrapper.find('.table-body').props().style.overflow).toEqual('auto');
});

it('renders with accessibility attributes when horizontally scrollable', () => {
const wrapper = mount(createTable({ scroll: { x: 200 } }));
const tableContainer = wrapper.find('.table-container').at(0);

expect(tableContainer.prop('role')).toBe('region');
expect(tableContainer.prop('tabIndex')).toBe(0);
});

it('does not render accessibility attributes when not horizontally scrollable', () => {
const wrapper = mount(createTable({ scroll: { y: 200 } }));
const tableContainer = wrapper.find('.table-container').at(0);

expect(tableContainer.prop('role')).toBeUndefined();
expect(tableContainer.prop('tabIndex')).toBeUndefined();
});

it('does not render accessibility attributes when no scroll prop', () => {
const wrapper = mount(createTable());
const tableContainer = wrapper.find('.table-container').at(0);

expect(tableContainer.prop('role')).toBeUndefined();
expect(tableContainer.prop('tabIndex')).toBeUndefined();
});

it('renders with accessibility attributes when scroll.x is true', () => {
const wrapper = mount(createTable({ scroll: { x: true } }));
const tableContainer = wrapper.find('.table-container').at(0);

expect(tableContainer.prop('role')).toBe('region');
expect(tableContainer.prop('tabIndex')).toBe(0);
});

it('renders with accessibility attributes when both scroll.x and scroll.y are set', () => {
const wrapper = mount(createTable({ scroll: { x: 200, y: 200 } }));
const tableContainer = wrapper.find('.table-container').at(0);

expect(tableContainer.prop('role')).toBe('region');
expect(tableContainer.prop('tabIndex')).toBe(0);
});

it('fire scroll event', () => {
jest.useFakeTimers();
let scrollLeft = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -16709,9 +16711,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -16709,9 +16711,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -13406,9 +13408,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -16709,9 +16711,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -16709,9 +16711,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -5402,9 +5404,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down Expand Up @@ -5525,6 +5531,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -12866,9 +12874,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -4358,9 +4360,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down Expand Up @@ -4481,6 +4487,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -10430,9 +10438,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -5402,9 +5404,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -7389,9 +7391,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -877,9 +879,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -17410,9 +17412,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ LoadedCheerio {
Node {
"attribs": Object {
"class": "table-container table-container-horizontally-scrollable",
"role": "region",
"tabindex": "0",
},
"children": Array [
Node {
Expand Down Expand Up @@ -17410,9 +17412,13 @@ LoadedCheerio {
"type": "tag",
"x-attribsNamespace": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
"x-attribsPrefix": Object {
"class": undefined,
"role": undefined,
"tabindex": undefined,
},
},
],
Expand Down
Loading