Skip to content

Commit cb22e29

Browse files
fix(eui): remove duplicated aria-label in pagination (#8597)
1 parent 11ee993 commit cb22e29

File tree

9 files changed

+18
-30
lines changed

9 files changed

+18
-30
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**Accessibility**
2+
3+
- Removed the `aria-label` attribute from the `ul` element in `EuiPagination` to avoid duplicate screen reader output
4+
- Set a more specific `aria-current="page"` on list items in `EuiPagination`

packages/eui/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,15 +962,14 @@ exports[`EuiBasicTable renders (kitchen sink) with pagination, selection, sortin
962962
/>
963963
</button>
964964
<ul
965-
aria-label="Pagination for table: "
966965
class="euiPagination__list emotion-euiPagination__list"
967966
>
968967
<li
969968
class="euiPagination__item"
970969
>
971970
<button
972971
aria-controls="__table_generated-id"
973-
aria-current="true"
972+
aria-current="page"
974973
aria-label="Page 1 of 2"
975974
class="euiButtonEmpty euiPaginationButton emotion-euiButtonDisplay-euiButtonEmpty-s-empty-disabled-isDisabled-euiPaginationButton-isActive"
976975
data-test-subj="pagination-button-0"

packages/eui/src/components/basic_table/__snapshots__/in_memory_table.test.tsx.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
8989
/>
9090
</a>
9191
<ul
92-
aria-label="Pagination for table: "
9392
class="euiPagination__list emotion-euiPagination__list"
9493
>
9594
<li
@@ -119,7 +118,7 @@ exports[`EuiInMemoryTable behavior pagination 1`] = `
119118
>
120119
<button
121120
aria-controls="__table_generated-id"
122-
aria-current="true"
121+
aria-current="page"
123122
aria-label="Page 2 of 2"
124123
class="euiButtonEmpty euiPaginationButton emotion-euiButtonDisplay-euiButtonEmpty-s-empty-disabled-isDisabled-euiPaginationButton-isActive"
125124
data-test-subj="pagination-button-1"

packages/eui/src/components/basic_table/basic_table.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ describe('EuiBasicTable', () => {
246246

247247
expect(getByRole('list')).toBeTruthy();
248248
expect(
249-
container.querySelector('[aria-current="true"]')?.textContent
249+
container.querySelector('[aria-current="page"]')?.textContent
250250
).toEqual('1');
251251
});
252252

@@ -264,7 +264,7 @@ describe('EuiBasicTable', () => {
264264
const { container } = render(<EuiBasicTable {...props} />);
265265

266266
expect(
267-
container.querySelector('[aria-current="true"]')?.textContent
267+
container.querySelector('[aria-current="page"]')?.textContent
268268
).toEqual('2');
269269
});
270270

packages/eui/src/components/datagrid/__snapshots__/data_grid.test.tsx.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ exports[`EuiDataGrid pagination renders 1`] = `
6363
/>
6464
</a>
6565
<ul
66-
aria-label="Pagination for preceding grid: test grid"
6766
class="euiPagination__list emotion-euiPagination__list"
6867
>
6968
<li
@@ -93,7 +92,7 @@ exports[`EuiDataGrid pagination renders 1`] = `
9392
>
9493
<button
9594
aria-controls="generated-id"
96-
aria-current="true"
95+
aria-current="page"
9796
aria-label="Page 2 of 2"
9897
class="euiButtonEmpty euiPaginationButton emotion-euiButtonDisplay-euiButtonEmpty-s-empty-disabled-isDisabled-euiPaginationButton-isActive"
9998
data-test-subj="pagination-button-1"

packages/eui/src/components/pagination/__snapshots__/pagination.test.tsx.snap

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ exports[`EuiPagination is rendered 1`] = `
2929
/>
3030
</button>
3131
<ul
32-
aria-label="aria-label"
3332
class="euiPagination__list emotion-euiPagination__list"
3433
>
3534
<li
3635
class="euiPagination__item"
3736
>
3837
<button
39-
aria-current="true"
38+
aria-current="page"
4039
aria-label="Page 1 of 1"
4140
class="euiButtonEmpty euiPaginationButton emotion-euiButtonDisplay-euiButtonEmpty-s-empty-disabled-isDisabled-euiPaginationButton-isActive"
4241
data-test-subj="pagination-button-0"
@@ -242,7 +241,7 @@ exports[`EuiPagination props activePage is rendered 1`] = `
242241
class="euiPagination__item"
243242
>
244243
<button
245-
aria-current="true"
244+
aria-current="page"
246245
aria-label="Page 6 of 10"
247246
class="euiButtonEmpty euiPaginationButton emotion-euiButtonDisplay-euiButtonEmpty-s-empty-disabled-isDisabled-euiPaginationButton-isActive"
248247
data-test-subj="pagination-button-5"
@@ -392,7 +391,7 @@ exports[`EuiPagination props aria-controls is rendered 1`] = `
392391
>
393392
<button
394393
aria-controls="idOfTable"
395-
aria-current="true"
394+
aria-current="page"
396395
aria-label="Page 1 of 1"
397396
class="euiButtonEmpty euiPaginationButton emotion-euiButtonDisplay-euiButtonEmpty-s-empty-disabled-isDisabled-euiPaginationButton-isActive"
398397
data-test-subj="pagination-button-0"
@@ -614,7 +613,7 @@ exports[`EuiPagination props pageCount is rendered 1`] = `
614613
class="euiPagination__item"
615614
>
616615
<button
617-
aria-current="true"
616+
aria-current="page"
618617
aria-label="Page 1 of 10"
619618
class="euiButtonEmpty euiPaginationButton emotion-euiButtonDisplay-euiButtonEmpty-s-empty-disabled-isDisabled-euiPaginationButton-isActive"
620619
data-test-subj="pagination-button-0"
@@ -789,7 +788,7 @@ exports[`EuiPagination props responsive can be customized 1`] = `
789788
class="euiPagination__item"
790789
>
791790
<button
792-
aria-current="true"
791+
aria-current="page"
793792
aria-label="Page 1 of 1"
794793
class="euiButtonEmpty euiPaginationButton emotion-euiButtonDisplay-euiButtonEmpty-s-empty-disabled-isDisabled-euiPaginationButton-isActive"
795794
data-test-subj="pagination-button-0"
@@ -858,7 +857,7 @@ exports[`EuiPagination props responsive can be false 1`] = `
858857
class="euiPagination__item"
859858
>
860859
<button
861-
aria-current="true"
860+
aria-current="page"
862861
aria-label="Page 1 of 1"
863862
class="euiButtonEmpty euiPaginationButton emotion-euiButtonDisplay-euiButtonEmpty-s-empty-disabled-isDisabled-euiPaginationButton-isActive"
864863
data-test-subj="pagination-button-0"

packages/eui/src/components/pagination/pagination.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -281,19 +281,8 @@ export const EuiPagination: FunctionComponent<Props> = ({
281281

282282
const selectablePages = pages;
283283

284-
const accessibleName = {
285-
...(rest['aria-label'] && { 'aria-label': rest['aria-label'] }),
286-
...(rest['aria-labelledby'] && {
287-
'aria-labelledby': rest['aria-labelledby'],
288-
}),
289-
};
290-
291284
centerPageCount = (
292-
<ul
293-
className="euiPagination__list"
294-
css={styles.euiPagination__list}
295-
{...accessibleName}
296-
>
285+
<ul className="euiPagination__list" css={styles.euiPagination__list}>
297286
{firstPageButtons}
298287
{selectablePages}
299288
{lastPageButtons}

packages/eui/src/components/pagination/pagination_button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const EuiPaginationButton: FunctionComponent<Props> = ({
5555
color: 'text',
5656
'data-test-subj': `pagination-button-${pageIndex}`,
5757
isDisabled: isActive,
58-
...(isActive && { 'aria-current': true }),
58+
...(isActive && { 'aria-current': 'page' }),
5959
...(rest['aria-controls'] && { href: `#${rest['aria-controls']}` }),
6060
...rest,
6161
};

packages/eui/src/components/table/table_pagination/__snapshots__/table_pagination.test.tsx.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ exports[`EuiTablePagination renders 1`] = `
6666
/>
6767
</button>
6868
<ul
69-
aria-label="aria-label"
7069
class="euiPagination__list emotion-euiPagination__list"
7170
>
7271
<li
@@ -93,7 +92,7 @@ exports[`EuiTablePagination renders 1`] = `
9392
class="euiPagination__item"
9493
>
9594
<button
96-
aria-current="true"
95+
aria-current="page"
9796
aria-label="Page 2 of 5"
9897
class="euiButtonEmpty euiPaginationButton emotion-euiButtonDisplay-euiButtonEmpty-s-empty-disabled-isDisabled-euiPaginationButton-isActive"
9998
data-test-subj="pagination-button-1"

0 commit comments

Comments
 (0)