Skip to content

Commit

Permalink
fix(material/tabs): use buttons for paginator (#14640)
Browse files Browse the repository at this point in the history
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 e8919bc)
  • Loading branch information
crisbeto authored and andrewseguin committed Jan 31, 2022
1 parent 8bd529b commit a634505
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/material/tabs/_tabs-common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ $tab-animation-duration: 500ms !default;
z-index: 2;
-webkit-tap-highlight-color: transparent;
touch-action: none;
box-sizing: content-box;
background: none;
border: none;
outline: 0;
padding: 0;

&::-moz-focus-inner {
border: 0;
}

.mat-tab-header-pagination-controls-enabled & {
display: flex;
Expand Down
20 changes: 14 additions & 6 deletions src/material/tabs/tab-nav-bar/tab-nav-bar.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<div class="mat-tab-header-pagination mat-tab-header-pagination-before mat-elevation-z4"
<button class="mat-tab-header-pagination mat-tab-header-pagination-before mat-elevation-z4"
#previousPaginator
aria-hidden="true"
mat-ripple [matRippleDisabled]="_disableScrollBefore || disableRipple"
type="button"
mat-ripple
tabindex="-1"
[matRippleDisabled]="_disableScrollBefore || disableRipple"
[class.mat-tab-header-pagination-disabled]="_disableScrollBefore"
[disabled]="_disableScrollBefore || null"
(click)="_handlePaginatorClick('before')"
(mousedown)="_handlePaginatorPress('before', $event)"
(touchend)="_stopInterval()">
<div class="mat-tab-header-pagination-chevron"></div>
</div>
</button>

<div class="mat-tab-link-container" #tabListContainer (keydown)="_handleKeydown($event)">
<div
Expand All @@ -22,13 +26,17 @@
</div>
</div>

<div class="mat-tab-header-pagination mat-tab-header-pagination-after mat-elevation-z4"
<button class="mat-tab-header-pagination mat-tab-header-pagination-after mat-elevation-z4"
#nextPaginator
aria-hidden="true"
mat-ripple [matRippleDisabled]="_disableScrollAfter || disableRipple"
type="button"
mat-ripple
[matRippleDisabled]="_disableScrollAfter || disableRipple"
[class.mat-tab-header-pagination-disabled]="_disableScrollAfter"
[disabled]="_disableScrollAfter || null"
tabindex="-1"
(mousedown)="_handlePaginatorPress('after', $event)"
(click)="_handlePaginatorClick('after')"
(touchend)="_stopInterval()">
<div class="mat-tab-header-pagination-chevron"></div>
</div>
</button>

0 comments on commit a634505

Please sign in to comment.