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

Commit 4d4e0ac

Browse files
committed
fix(nav-bar): clicked nav item not focused or selected in some cases
reduce unnecessary calls to onFocus() and setFocused() - in some cases, instead of focusing a nav item that was clicked on we would focus the selected nav item Fixes #11747
1 parent 498c9ed commit 4d4e0ac

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/components/navBar/navBar.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ MdNavBarController.prototype._initTabs = function() {
174174

175175
var self = this;
176176
this._$timeout(function() {
177-
self._updateTabs(self.mdSelectedNavItem, undefined);
177+
self._updateTabs(self.mdSelectedNavItem, null);
178178
});
179179

180180
this._$scope.$watch('ctrl.mdSelectedNavItem', function(newValue, oldValue) {
@@ -189,7 +189,7 @@ MdNavBarController.prototype._initTabs = function() {
189189
/**
190190
* Set the current tab to be selected.
191191
* @param {string|undefined} newValue New current tab name.
192-
* @param {string|undefined} oldValue Previous tab name.
192+
* @param {string|undefined|null} oldValue Previous tab name.
193193
* @private
194194
*/
195195
MdNavBarController.prototype._updateTabs = function(newValue, oldValue) {
@@ -335,7 +335,7 @@ MdNavBarController.prototype._findTabReverse = function(fn, startIndex) {
335335
*/
336336
MdNavBarController.prototype.onFocus = function() {
337337
var tab = this._getSelectedTab();
338-
if (tab) {
338+
if (tab && !tab._focused) {
339339
tab.setFocused(true);
340340
}
341341
};
@@ -595,9 +595,7 @@ function MdNavItem($mdAria, $$rAF, $mdUtil, $window) {
595595
});
596596

597597
navButton.on('focus', function() {
598-
if (!mdNavBar.getFocusedTab()) {
599-
mdNavBar.onFocus();
600-
}
598+
mdNavItem._focused = true;
601599
});
602600

603601
navButton.on('click', function() {

0 commit comments

Comments
 (0)