Skip to content

Commit

Permalink
fix(HeaderMenu,HeaderNavigation): handle null item (#4682)
Browse files Browse the repository at this point in the history
* fix(HeaderMenu): handle null item

* fix(HeaderNavigation): handle null item
  • Loading branch information
breid1313 authored and joshblack committed Nov 15, 2019
1 parent a4785f3 commit e8888a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions packages/react/src/components/UIShell/HeaderMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,12 @@ class HeaderMenu extends React.Component {
* sequence when they might not want to go through all the items.
*/
_renderMenuItem = (item, index) => {
return React.cloneElement(item, {
ref: this.handleItemRef(index),
role: 'none',
});
if (React.isValidElement(item)) {
return React.cloneElement(item, {
ref: this.handleItemRef(index),
role: 'none',
});
}
};
}

Expand Down
8 changes: 5 additions & 3 deletions packages/react/src/components/UIShell/HeaderNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ export default class HeaderNavigation extends React.Component {
* `this.items` to properly manage focus.
*/
_renderNavItem = (child, index) => {
return React.cloneElement(child, {
ref: this.handleItemRef(index),
});
if (React.isValidElement(child)) {
return React.cloneElement(child, {
ref: this.handleItemRef(index),
});
}
};
}

0 comments on commit e8888a1

Please sign in to comment.