Skip to content

Commit 149e8c7

Browse files
johannes-weberJohannes Weber
andauthored
chore: Remove selectionGroupLabel from table's selection controls (#3492)
Co-authored-by: Johannes Weber <[email protected]>
1 parent 8565ca4 commit 149e8c7

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

src/s3-resource-selector/s3-modal/__tests__/buckets-table.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function findRefreshButton(wrapper: TableWrapper) {
3232

3333
test('Renders correct aria-labels', async () => {
3434
const wrapper = await renderTable(<BucketsTable {...defaultProps} />);
35-
expect(wrapper.findRowSelectionArea(1)!.getElement()).toHaveAttribute('aria-label', 'Buckets select bucket-laborum');
35+
expect(wrapper.findRowSelectionArea(1)!.getElement()).toHaveAttribute('aria-label', 'select bucket-laborum');
3636
expect(wrapper.findTextFilter()!.findInput().findNativeInput().getElement()).toHaveAttribute(
3737
'aria-label',
3838
'Find Buckets'

src/s3-resource-selector/s3-modal/__tests__/objects-table.test.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,7 @@ test('uses I18nProvider for folder and file icons', async () => {
134134

135135
test('Renders selection labels', async () => {
136136
const wrapper = await renderTable(<ObjectsTable {...defaultProps} />);
137-
expect(wrapper.findRowSelectionArea(1)!.getElement()).toHaveAttribute(
138-
'aria-label',
139-
'Objects select simulation-nano-2019'
140-
);
137+
expect(wrapper.findRowSelectionArea(1)!.getElement()).toHaveAttribute('aria-label', 'select simulation-nano-2019');
141138
});
142139

143140
test('allows selecting an object', async () => {

src/s3-resource-selector/s3-modal/__tests__/versions-table.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ test('Renders selection labels', async () => {
6565
const wrapper = await renderTable(<VersionsTable {...defaultProps} />);
6666
expect(wrapper.findRowSelectionArea(1)!.getElement()).toHaveAttribute(
6767
'aria-label',
68-
'Versions select 6036589969ec3d9b2db8faa7'
68+
'select 6036589969ec3d9b2db8faa7'
6969
);
7070
});
7171

src/table/__tests__/selection.test.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ describe('Selection controls` labelling', () => {
8383

8484
test('puts selectionGroupLabel and allItemsSelectionLabel on selectAll checkbox', () => {
8585
tableWrapper = renderTable({ selectionType: 'multi', selectedItems: [items[0]], ariaLabels }).wrapper;
86-
expect(tableWrapper.findSelectAllTrigger()?.getElement()).toHaveAttribute(
87-
'aria-label',
88-
'group label 1 item selected'
89-
);
86+
expect(tableWrapper.findSelectAllTrigger()?.getElement()).toHaveAttribute('aria-label', '1 item selected');
9087
});
9188

9289
test('puts selectionGroupLabel on single selection column header', () => {
@@ -108,15 +105,26 @@ describe('Selection controls` labelling', () => {
108105
tableWrapper = renderTable({ selectionType, ariaLabels, selectedItems: [items[1]] }).wrapper;
109106
expect(tableWrapper.findRowSelectionArea(1)?.getElement()).toHaveAttribute(
110107
'aria-label',
111-
'group label Apples is not selected'
112-
);
113-
expect(tableWrapper.findRowSelectionArea(2)?.getElement()).toHaveAttribute(
114-
'aria-label',
115-
'group label Oranges is selected'
108+
'Apples is not selected'
116109
);
110+
expect(tableWrapper.findRowSelectionArea(2)?.getElement()).toHaveAttribute('aria-label', 'Oranges is selected');
117111
expect(tableWrapper.findRowSelectionArea(3)?.getElement()).toHaveAttribute(
118112
'aria-label',
119-
'group label Bananas is not selected'
113+
'Bananas is not selected'
114+
);
115+
});
116+
117+
test('does not put selectionGroupLabel on row selection control', () => {
118+
tableWrapper = renderTable({ selectionType, ariaLabels, selectedItems: [items[1]] }).wrapper;
119+
120+
expect(tableWrapper.findRowSelectionArea(1)!.getElement().getAttribute('aria-label')).toEqual(
121+
expect.not.stringContaining('group label')
122+
);
123+
expect(tableWrapper.findRowSelectionArea(2)!.getElement().getAttribute('aria-label')).toEqual(
124+
expect.not.stringContaining('group label')
125+
);
126+
expect(tableWrapper.findRowSelectionArea(3)!.getElement().getAttribute('aria-label')).toEqual(
127+
expect.not.stringContaining('group label')
120128
);
121129
});
122130
});

src/table/internal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ const InternalTable = React.forwardRef(
303303
selectionType,
304304
isItemDisabled,
305305
onSelectionChange,
306-
ariaLabels,
306+
ariaLabels: {
307+
...ariaLabels,
308+
// `selectionGroupLabel` should not be part of the selection control, it is already part of the selection column header.
309+
selectionGroupLabel: undefined,
310+
},
307311
loading,
308312
setLastUserAction,
309313
});

0 commit comments

Comments
 (0)