Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 4b1b729

Browse files
Splaktarmmalerba
authored andcommitted
fix(tabs): provide guidance on how to navigate between tabs (#11402)
make sure that this message can be overridden in non-English locales Fixes #10895
1 parent e56424e commit 4b1b729

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/components/tabs/js/tabsController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
7878
ctrl.styleTabItemFocus = false;
7979
ctrl.shouldCenterTabs = shouldCenterTabs();
8080
ctrl.tabContentPrefix = 'tab-content-';
81+
ctrl.navigationHint = 'Use the left and right arrow keys to navigate between tabs';
8182

8283
// Setup the tabs controller after all bindings are available.
8384
setupTabsController();
@@ -956,8 +957,7 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
956957
}
957958

958959
/**
959-
* Sets the `aria-controls` attribute to the elements that
960-
* correspond to the passed-in tab.
960+
* Sets the `aria-controls` attribute to the elements that correspond to the passed-in tab.
961961
* @param tab
962962
*/
963963
function setAriaControls (tab) {

src/components/tabs/js/tabsDirective.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@
8989
* @param {boolean=} md-no-select-click When true, click events will not be fired when the value of
9090
* `md-active` on an `md-tab` changes. This is useful when using tabs with UI-Router's child
9191
* states, as triggering a click event in that case can cause an extra tab change to occur.
92+
* @param {string=} md-navigation-hint Attribute to override the default `tablist` navigation hint
93+
* that screen readers will announce to provide instructions for navigating between tabs. This is
94+
* desirable when you want the hint to be in a different language. Default is "Use the left and
95+
* right arrow keys to navigate between tabs".
9296
*
9397
* @usage
9498
* <hljs lang="html">
@@ -118,6 +122,7 @@ angular
118122
function MdTabs ($$mdSvgRegistry) {
119123
return {
120124
scope: {
125+
navigationHint: '@?mdNavigationHint',
121126
selectedIndex: '=?mdSelected'
122127
},
123128
template: function (element, attr) {
@@ -156,7 +161,8 @@ function MdTabs ($$mdSvgRegistry) {
156161
'<md-pagination-wrapper ' +
157162
'ng-class="{ \'md-center-tabs\': $mdTabsCtrl.shouldCenterTabs }" ' +
158163
'md-tab-scroll="$mdTabsCtrl.scroll($event)" ' +
159-
'role="tablist"> ' +
164+
'role="tablist" ' +
165+
'aria-label="{{::$mdTabsCtrl.navigationHint}}">' +
160166
'<md-tab-item ' +
161167
'tabindex="{{ tab.isActive() ? 0 : -1 }}" ' +
162168
'class="md-tab" ' +

0 commit comments

Comments
 (0)