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

Commit ec9aa25

Browse files
Splaktarmmalerba
authored andcommitted
fix(nav-bar): non-selected tabs with anchors have invalid tabindex value (#11675)
md-button was applying tabindex="0" to all non-disabled anchors this affects md-nav-sref and md-nav-href Fixes #11637
1 parent d56d0e7 commit ec9aa25

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/components/button/button.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ function MdButtonDirective($mdButtonInkRipple, $mdTheming, $mdAria, $mdInteracti
146146
// Use async expect to support possible bindings in the button label
147147
$mdAria.expectWithoutText(element, 'aria-label');
148148

149-
// For anchor elements, we have to set tabindex manually when the
150-
// element is disabled
151-
if (isAnchor(attr) && angular.isDefined(attr.ngDisabled)) {
149+
// For anchor elements, we have to set tabindex manually when the element is disabled.
150+
// We don't do this for md-nav-bar anchors as the component manages its own tabindex values.
151+
if (isAnchor(attr) && angular.isDefined(attr.ngDisabled) &&
152+
!element.hasClass('_md-nav-button')) {
152153
scope.$watch(attr.ngDisabled, function(isDisabled) {
153154
element.attr('tabindex', isDisabled ? -1 : 0);
154155
});

src/components/navBar/navBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ MdNavItemController.prototype.getButtonEl = function() {
710710
};
711711

712712
/**
713-
* Set the selected state of the tab and update the tabindex.
713+
* Set the selected state of the tab and updates the tabindex.
714714
* This function is called for the oldTab and newTab when selection changes.
715715
* @param {boolean} isSelected true to select the tab, false to deselect the tab
716716
*/

0 commit comments

Comments
 (0)