From 365c7dd65e40b6f5cf192bef540d8cd509e8870a Mon Sep 17 00:00:00 2001
From: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
Date: Thu, 21 Nov 2024 04:06:07 +1000
Subject: [PATCH] [CL] add `hideIfEmpty` input to bit-nav-group (#12046)
---
.../src/navigation/nav-group.component.html | 98 ++++++++++---------
.../src/navigation/nav-group.component.ts | 7 ++
.../src/navigation/nav-group.stories.ts | 24 +++++
3 files changed, 81 insertions(+), 48 deletions(-)
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 @@
-
-
-
-
+ 0">
+
+
+
+
-
-
-
-
-
-
-
+
+
-
-
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
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,