diff --git a/libs/components/src/navigation/nav-group.component.html b/libs/components/src/navigation/nav-group.component.html index c22a067ffed..9f6d9ac034d 100644 --- a/libs/components/src/navigation/nav-group.component.html +++ b/libs/components/src/navigation/nav-group.component.html @@ -1,54 +1,56 @@ - - - - + + + + + - - - - - - - + + - - + + + + + + + - - -
- -
+ + +
+ +
+
diff --git a/libs/components/src/navigation/nav-group.component.ts b/libs/components/src/navigation/nav-group.component.ts index 1ebe7338648..07494c0b7da 100644 --- a/libs/components/src/navigation/nav-group.component.ts +++ b/libs/components/src/navigation/nav-group.component.ts @@ -1,5 +1,6 @@ import { AfterContentInit, + booleanAttribute, Component, ContentChildren, EventEmitter, @@ -40,6 +41,12 @@ export class NavGroupComponent extends NavBaseComponent implements AfterContentI @Input() open = false; + /** + * Automatically hide the nav group if there are no child buttons + */ + @Input({ transform: booleanAttribute }) + hideIfEmpty = false; + @Output() openChange = new EventEmitter(); diff --git a/libs/components/src/navigation/nav-group.stories.ts b/libs/components/src/navigation/nav-group.stories.ts index de150ebc0d7..a6fa53ff187 100644 --- a/libs/components/src/navigation/nav-group.stories.ts +++ b/libs/components/src/navigation/nav-group.stories.ts @@ -88,6 +88,30 @@ export const Default: StoryObj = { }), }; +export const HideEmptyGroups: StoryObj = { + args: { + hideIfEmpty: true, + renderChildren: false, + }, + render: (args) => ({ + props: args, + template: /*html*/ ` + + + + + + + + + + + + + `, + }), +}; + export const Tree: StoryObj = { render: (args) => ({ props: args,