From 8926d8a90e58bf7e507aceb0b6a965bf3726055a Mon Sep 17 00:00:00 2001 From: "Ahmad K. Bawaneh" Date: Sun, 22 Sep 2024 09:29:27 +0300 Subject: [PATCH] fix #955 Empty submenu opens as horizontal line. --- .../org/dominokit/domino/ui/menu/Menu.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/domino-ui/src/main/java/org/dominokit/domino/ui/menu/Menu.java b/domino-ui/src/main/java/org/dominokit/domino/ui/menu/Menu.java index 7b6f08022..0abe13f58 100644 --- a/domino-ui/src/main/java/org/dominokit/domino/ui/menu/Menu.java +++ b/domino-ui/src/main/java/org/dominokit/domino/ui/menu/Menu.java @@ -1301,15 +1301,26 @@ public Menu setBordered(boolean bordered) { * @return The current {@link Menu} instance. */ public Menu openSubMenu(Menu 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. *