Skip to content

Commit

Permalink
fix(ui5-menu): opening a submenu no longer throws a console error (#5591
Browse files Browse the repository at this point in the history
)

fixes: #5582
  • Loading branch information
tsanislavgatev authored Aug 1, 2022
1 parent e818f28 commit 1b5caf7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/main/src/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,11 @@ class Menu extends UI5Element {
}

_prepareSubMenuDesktopTablet(item, opener, actionId) {
if (actionId !== this._subMenuOpenerId || item.hasChildren) {
if (actionId !== this._subMenuOpenerId || (item && item.hasChildren)) {
// close opened sub-menu if there is any opened
this._closeItemSubMenu(this._openedSubMenuItem, true);
}
if (item.hasChildren) {
if (item && item.hasChildren) {
// create new sub-menu
this._createSubMenu(item, actionId);
this._openItemSubMenu(item, opener, actionId);
Expand Down Expand Up @@ -434,7 +434,7 @@ class Menu extends UI5Element {
// respect mouseover only on desktop
const item = event.target.associatedItem;

if (item.hasChildren && item._subMenu) {
if (item && item.hasChildren && item._subMenu) {
// try to close the sub-menu
item._preventSubMenuClose = false;
this._closeItemSubMenu(item);
Expand Down

0 comments on commit 1b5caf7

Please sign in to comment.