Skip to content

Commit

Permalink
fix #955 Empty submenu opens as horizontal line.
Browse files Browse the repository at this point in the history
  • Loading branch information
vegegoku committed Sep 22, 2024
1 parent 4864029 commit 8926d8a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions domino-ui/src/main/java/org/dominokit/domino/ui/menu/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -1301,15 +1301,26 @@ public Menu<V> setBordered(boolean bordered) {
* @return The current {@link Menu} instance.
*/
public Menu<V> openSubMenu(Menu<V> dropMenu) {
if (!Objects.equals(currentOpen, dropMenu)) {
closeCurrentOpen();
if (dropMenu.hasVisibleItems()) {
if (!Objects.equals(currentOpen, dropMenu)) {
closeCurrentOpen();
}
dropMenu.open();
setCurrentOpen(dropMenu);
}
dropMenu.open();
setCurrentOpen(dropMenu);

return this;
}

private boolean hasVisibleItems() {
for (int index = 0; index < menuItems.size(); index++) {
if (menuItems.get(index).isVisible()) {
return true;
}
}
return false;
}

/**
* Sets the current open submenu.
*
Expand Down

0 comments on commit 8926d8a

Please sign in to comment.