Skip to content

Commit 5e41a0a

Browse files
jeripeierSBBandrewseguin
authored andcommitted
fix(material/tabs): use buttons for paginator also tab-header and mdc (#24338)
This is a follow-up PR to #14640 / e8919bc I think these other templates should be updated to button usage too, so we can keep consistency. Uses `button` elements, rather than styled `div`-s for the paginator buttons. This has the advantage of being more accessible, if we decided to make them focusable, and it stops calling the click listeners when the button is disabled (currently we do some expensive checks in them when we don't have to). (cherry picked from commit d9ad68a)
1 parent 39d7834 commit 5e41a0a

File tree

4 files changed

+48
-17
lines changed

4 files changed

+48
-17
lines changed

src/material-experimental/mdc-tabs/_tabs-common.scss

+9
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ $mat-tab-animation-duration: 500ms !default;
104104
z-index: 2;
105105
-webkit-tap-highlight-color: transparent;
106106
touch-action: none;
107+
box-sizing: content-box;
108+
background: none;
109+
border: none;
110+
outline: 0;
111+
padding: 0;
112+
113+
&::-moz-focus-inner {
114+
border: 0;
115+
}
107116

108117
.mat-ripple-element {
109118
opacity: map.get(mdc-ripple.$dark-ink-opacities, press);

src/material-experimental/mdc-tabs/tab-header.html

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
<!-- TODO: this also had `mat-elevation-z4`. Figure out what we should do with it. -->
2-
<div class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-before"
2+
<button class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-before"
33
#previousPaginator
44
aria-hidden="true"
5+
type="button"
56
mat-ripple
7+
tabindex="-1"
68
[matRippleDisabled]="_disableScrollBefore || disableRipple"
79
[class.mat-mdc-tab-header-pagination-disabled]="_disableScrollBefore"
10+
[disabled]="_disableScrollBefore || null"
811
(click)="_handlePaginatorClick('before')"
912
(mousedown)="_handlePaginatorPress('before', $event)"
1013
(touchend)="_stopInterval()">
1114
<div class="mat-mdc-tab-header-pagination-chevron"></div>
12-
</div>
15+
</button>
1316

1417
<div
1518
class="mat-mdc-tab-label-container"
@@ -28,14 +31,17 @@
2831
</div>
2932

3033
<!-- TODO: this also had `mat-elevation-z4`. Figure out what we should do with it. -->
31-
<div class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-after"
34+
<button class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-after"
3235
#nextPaginator
3336
aria-hidden="true"
37+
type="button"
3438
mat-ripple
3539
[matRippleDisabled]="_disableScrollAfter || disableRipple"
36-
[class.mat-mdc-tab-header-pagination-disabled]="_disableScrollAfter"
40+
[class.mat-mdc-header-pagination-disabled]="_disableScrollAfter"
41+
[disabled]="_disableScrollAfter || null"
42+
tabindex="-1"
3743
(mousedown)="_handlePaginatorPress('after', $event)"
3844
(click)="_handlePaginatorClick('after')"
3945
(touchend)="_stopInterval()">
4046
<div class="mat-mdc-tab-header-pagination-chevron"></div>
41-
</div>
47+
</button>
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
<!-- TODO: this also had `mat-elevation-z4`. Figure out what we should do with it. -->
2-
<div class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-before"
2+
<button class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-before"
33
#previousPaginator
44
aria-hidden="true"
5-
mat-ripple [matRippleDisabled]="_disableScrollBefore || disableRipple"
5+
type="button"
6+
mat-ripple
7+
tabindex="-1"
8+
[matRippleDisabled]="_disableScrollBefore || disableRipple"
69
[class.mat-mdc-tab-header-pagination-disabled]="_disableScrollBefore"
10+
[disabled]="_disableScrollBefore || null"
711
(click)="_handlePaginatorClick('before')"
812
(mousedown)="_handlePaginatorPress('before', $event)"
913
(touchend)="_stopInterval()">
1014
<div class="mat-mdc-tab-header-pagination-chevron"></div>
11-
</div>
15+
</button>
1216

1317
<div class="mat-mdc-tab-link-container" #tabListContainer (keydown)="_handleKeydown($event)">
1418
<div class="mat-mdc-tab-list" #tabList (cdkObserveContent)="_onContentChanges()">
@@ -19,13 +23,17 @@
1923
</div>
2024

2125
<!-- TODO: this also had `mat-elevation-z4`. Figure out what we should do with it. -->
22-
<div class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-after"
26+
<button class="mat-mdc-tab-header-pagination mat-mdc-tab-header-pagination-after"
2327
#nextPaginator
2428
aria-hidden="true"
25-
mat-ripple [matRippleDisabled]="_disableScrollAfter || disableRipple"
29+
type="button"
30+
mat-ripple
31+
[matRippleDisabled]="_disableScrollAfter || disableRipple"
2632
[class.mat-mdc-tab-header-pagination-disabled]="_disableScrollAfter"
33+
[disabled]="_disableScrollAfter || null"
34+
tabindex="-1"
2735
(mousedown)="_handlePaginatorPress('after', $event)"
2836
(click)="_handlePaginatorClick('after')"
2937
(touchend)="_stopInterval()">
3038
<div class="mat-mdc-tab-header-pagination-chevron"></div>
31-
</div>
39+
</button>

src/material/tabs/tab-header.html

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
<div class="mat-tab-header-pagination mat-tab-header-pagination-before mat-elevation-z4"
1+
<button class="mat-tab-header-pagination mat-tab-header-pagination-before mat-elevation-z4"
22
#previousPaginator
33
aria-hidden="true"
4-
mat-ripple [matRippleDisabled]="_disableScrollBefore || disableRipple"
4+
type="button"
5+
mat-ripple
6+
tabindex="-1"
7+
[matRippleDisabled]="_disableScrollBefore || disableRipple"
58
[class.mat-tab-header-pagination-disabled]="_disableScrollBefore"
9+
[disabled]="_disableScrollBefore || null"
610
(click)="_handlePaginatorClick('before')"
711
(mousedown)="_handlePaginatorPress('before', $event)"
812
(touchend)="_stopInterval()">
913
<div class="mat-tab-header-pagination-chevron"></div>
10-
</div>
14+
</button>
1115

1216
<div class="mat-tab-label-container" #tabListContainer (keydown)="_handleKeydown($event)">
1317
<div
@@ -23,13 +27,17 @@
2327
</div>
2428
</div>
2529

26-
<div class="mat-tab-header-pagination mat-tab-header-pagination-after mat-elevation-z4"
30+
<button class="mat-tab-header-pagination mat-tab-header-pagination-after mat-elevation-z4"
2731
#nextPaginator
2832
aria-hidden="true"
29-
mat-ripple [matRippleDisabled]="_disableScrollAfter || disableRipple"
33+
type="button"
34+
mat-ripple
35+
[matRippleDisabled]="_disableScrollAfter || disableRipple"
3036
[class.mat-tab-header-pagination-disabled]="_disableScrollAfter"
37+
[disabled]="_disableScrollAfter || null"
38+
tabindex="-1"
3139
(mousedown)="_handlePaginatorPress('after', $event)"
3240
(click)="_handlePaginatorClick('after')"
3341
(touchend)="_stopInterval()">
3442
<div class="mat-tab-header-pagination-chevron"></div>
35-
</div>
43+
</button>

0 commit comments

Comments
 (0)