Skip to content

Commit 357f6f2

Browse files
authored
fix(material/tabs): switch pagination to not use native buttons (#29605)
These changes undo #14640 and #24338 since they are causing Chrome to log accessibility warnings. We don't want to use native `button` elements here, because they're always focusable (unless disabled) and these buttons should be completely invisible to assistive technology. AT users can navigate the tabs directly without having to use the pagination.
1 parent 04ce4d2 commit 357f6f2

File tree

3 files changed

+16
-27
lines changed

3 files changed

+16
-27
lines changed

src/material/tabs/_tabs-common.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,7 @@ $mat-tab-animation-duration: 500ms !default;
300300
-webkit-tap-highlight-color: transparent;
301301
touch-action: none;
302302
box-sizing: content-box;
303-
background: none;
304-
border: none;
305303
outline: 0;
306-
padding: 0;
307304

308305
&::-moz-focus-inner {
309306
border: 0;

src/material/tabs/tab-header.html

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<button class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-before"
1+
<!--
2+
Note that this intentionally uses a `div` instead of a `button`, because it's not part of
3+
the regular tabs flow and is only here to support mouse users. It should also not be focusable.
4+
-->
5+
<div class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-before"
26
#previousPaginator
3-
aria-hidden="true"
4-
type="button"
57
mat-ripple
6-
tabindex="-1"
78
[matRippleDisabled]="_disableScrollBefore || disableRipple"
89
[class.mat-mdc-tab-header-pagination-disabled]="_disableScrollBefore"
9-
[disabled]="_disableScrollBefore || null"
1010
(click)="_handlePaginatorClick('before')"
1111
(mousedown)="_handlePaginatorPress('before', $event)"
1212
(touchend)="_stopInterval()">
1313
<div class="mat-mdc-tab-header-pagination-chevron"></div>
14-
</button>
14+
</div>
1515

1616
<div
1717
class="mat-mdc-tab-label-container"
@@ -31,17 +31,13 @@
3131
</div>
3232
</div>
3333

34-
<button class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-after"
34+
<div class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-after"
3535
#nextPaginator
36-
aria-hidden="true"
37-
type="button"
3836
mat-ripple
3937
[matRippleDisabled]="_disableScrollAfter || disableRipple"
4038
[class.mat-mdc-tab-header-pagination-disabled]="_disableScrollAfter"
41-
[disabled]="_disableScrollAfter || null"
42-
tabindex="-1"
4339
(mousedown)="_handlePaginatorPress('after', $event)"
4440
(click)="_handlePaginatorClick('after')"
4541
(touchend)="_stopInterval()">
4642
<div class="mat-mdc-tab-header-pagination-chevron"></div>
47-
</button>
43+
</div>
Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<button class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-before"
1+
<!--
2+
Note that this intentionally uses a `div` instead of a `button`, because it's not part of
3+
the regular tabs flow and is only here to support mouse users. It should also not be focusable.
4+
-->
5+
<div class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-before"
26
#previousPaginator
3-
aria-hidden="true"
4-
type="button"
57
mat-ripple
6-
tabindex="-1"
78
[matRippleDisabled]="_disableScrollBefore || disableRipple"
89
[class.mat-mdc-tab-header-pagination-disabled]="_disableScrollBefore"
9-
[disabled]="_disableScrollBefore || null"
1010
(click)="_handlePaginatorClick('before')"
1111
(mousedown)="_handlePaginatorPress('before', $event)"
1212
(touchend)="_stopInterval()">
1313
<div class="mat-mdc-tab-header-pagination-chevron"></div>
14-
</button>
14+
</div>
1515

1616
<div class="mat-mdc-tab-link-container" #tabListContainer (keydown)="_handleKeydown($event)">
1717
<div class="mat-mdc-tab-list" #tabList (cdkObserveContent)="_onContentChanges()">
@@ -21,17 +21,13 @@
2121
</div>
2222
</div>
2323

24-
<button class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-after"
24+
<div class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-after"
2525
#nextPaginator
26-
aria-hidden="true"
27-
type="button"
2826
mat-ripple
2927
[matRippleDisabled]="_disableScrollAfter || disableRipple"
3028
[class.mat-mdc-tab-header-pagination-disabled]="_disableScrollAfter"
31-
[disabled]="_disableScrollAfter || null"
32-
tabindex="-1"
3329
(mousedown)="_handlePaginatorPress('after', $event)"
3430
(click)="_handlePaginatorClick('after')"
3531
(touchend)="_stopInterval()">
3632
<div class="mat-mdc-tab-header-pagination-chevron"></div>
37-
</button>
33+
</div>

0 commit comments

Comments
 (0)