Templarian / ui.bootstrap.contextMenu

AngularJS Bootstrap UI Context Menu
MIT License
259 stars 127 forks source link

Hide menu when it is empty #123

Closed lafeuil closed 7 years ago

lafeuil commented 7 years ago

When I create a context menu and all submenus are the displayed property to false, a small context menu is displayed with nothing.

Technically, the ul element of context menu is displayed but it contains empty li elements :

<ul class="dropdown-menu" role="menu">
  <li></li>
  <li></li>
</ul>

I think if a submenu have its displayed property to false, the li element should not be added to ul element. With this, you can check if the ul element contains element. If it is empty, you can hide it or not remove to html.

josetaira commented 7 years ago

In general it should really show something like "No items to show" or "No items" if there are no items in that level of the context menu. This text could be configured as a passed prop. If you really wanted to not show anything for empty sub-menus you can choose to set the children as undefined/null.

On a separate note, the actual bug is that it shouldn't be adding any <li> elements.

josetaira commented 7 years ago

The part that prevents <li> should already be checked in with https://github.com/Templarian/ui.bootstrap.contextMenu/commit/87012810e095f3847f367c159dd2f28938cd3634

lafeuil commented 7 years ago

Do you think it is possible to add an option to configure the text of the item that appears when all items is hide ? Currently the message displayed is "empty".

josetaira commented 7 years ago

Yeah, this is something I'll be adding in a while. I just put up "empty" for now as the current placeholder. Maybe just a context-menu-empty-text property