-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(nav-bar): null check tabs when updating nav-bar #9071
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
1 similar comment
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
Signed CLA |
CLAs look good, thanks! |
1 similar comment
CLAs look good, thanks! |
Please provide 1-2 unit tests for these. Thx @samdlt . |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
CLAs look good, thanks! |
1 similar comment
CLAs look good, thanks! |
@ThomasBurleson added unit tests |
oldTab.setSelected(false); | ||
oldIndex = tabs.indexOf(oldTab); | ||
} | ||
if (tabs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent nesting, we can change this to if (!tabs) return;
. We can also move it up to before oldIndex
and newIndex
are initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, can you return immediately and as soon as possible?
Fixes #9386 Can you add that to the commit message? |
.map(function(el) { | ||
return angular.element(el).controller('mdNavItem') | ||
}); | ||
return linkArray.indexOf() === -1 ? linkArray : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linkArray.indexOf(undefined)
reads a little better to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
controllers
instead of linkArray
plz.
@gmoothart @clshortfuse Thanks for taking a look at this guys. I'll address the comments either tomorrow or Monday. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, pending some minor comments.
@@ -209,6 +209,10 @@ MdNavBarController.prototype._initTabs = function() { | |||
MdNavBarController.prototype._updateTabs = function(newValue, oldValue) { | |||
var self = this; | |||
var tabs = this._getTabs(); | |||
|
|||
if(!tabs) | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment here explaining why tabs might be null?
@samdlt - FYI, we will not merge until the review feedback is addressed and the PR refreshed with updates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -209,6 +209,11 @@ MdNavBarController.prototype._initTabs = function() { | |||
MdNavBarController.prototype._updateTabs = function(newValue, oldValue) { | |||
var self = this; | |||
var tabs = this._getTabs(); | |||
|
|||
// this._getTabs can return an array of undefined if nav-bar has not yet been initialized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) technically it returns null, not an array of undefined.
@samdlt can you resolve the merge conflicts and then we can merge this? |
@gmoothart merged and resolved conflict |
@samdlt can you rebase? |
@jelbourn rebased |
It is possible that _getTabs returns an array of undefined when mapping over linkArray as .controller('mdNavItem') can return undefined if it cannot find the corresponding controller which will cause an error to be shown in the console during the digest cycle.
This change assures that we do not attempt to update the tabs in the case that tabs is an undefined array.