From 1b755124a9750c877ffc831b5fdf0528b8fa7de7 Mon Sep 17 00:00:00 2001 From: Karan Mistry Date: Wed, 6 May 2026 12:35:31 +0530 Subject: [PATCH] feat(navbar-vertical-next): add alwaysOpenGroupsInFlyout mode - Add `alwaysOpenGroupsInFlyout` input to open groups as flyout panels on click, regardless of collapsed state - Switch caret icon from down to right when flyout mode is active Closes #1944 --- .../navbar-vertical-next/index.api.md | 4 +- ...r-vertical-next-group-trigger.directive.ts | 10 +- ...si-navbar-vertical-next-group.component.ts | 6 +- ...i-navbar-vertical-next-item.component.html | 5 +- ...i-navbar-vertical-next-item.component.scss | 4 + ...avbar-vertical-next-item.component.spec.ts | 53 ++++++++++ .../si-navbar-vertical-next-item.component.ts | 10 +- .../si-navbar-vertical-next.component.ts | 9 ++ .../si-navbar-vertical-next.spec.ts | 13 +++ ...si-navbar-vertical-next-always-flyout.html | 96 +++++++++++++++++++ .../si-navbar-vertical-next-always-flyout.ts | 59 ++++++++++++ 11 files changed, 260 insertions(+), 9 deletions(-) create mode 100644 src/app/examples/si-navbar-vertical-next/si-navbar-vertical-next-always-flyout.html create mode 100644 src/app/examples/si-navbar-vertical-next/si-navbar-vertical-next-always-flyout.ts diff --git a/api-goldens/element-ng/navbar-vertical-next/index.api.md b/api-goldens/element-ng/navbar-vertical-next/index.api.md index 23b85dfce7..35757dcc6e 100644 --- a/api-goldens/element-ng/navbar-vertical-next/index.api.md +++ b/api-goldens/element-ng/navbar-vertical-next/index.api.md @@ -6,6 +6,7 @@ import * as _angular_core from '@angular/core'; import { OnChanges } from '@angular/core'; +import { OnDestroy } from '@angular/core'; import { OnInit } from '@angular/core'; import * as _siemens_element_ng_navbar_vertical_next from '@siemens/element-ng/navbar-vertical-next'; import * as _siemens_element_translate_ng_translate from '@siemens/element-translate-ng/translate'; @@ -15,6 +16,7 @@ import { TemplateRef } from '@angular/core'; // @public (undocumented) export class SiNavbarVerticalNextComponent implements OnChanges, OnInit { constructor(); + readonly alwaysOpenGroupsInFlyout: _angular_core.InputSignalWithTransform; collapse(): void; readonly collapsed: _angular_core.ModelSignal; expand(): void; @@ -44,7 +46,7 @@ export class SiNavbarVerticalNextGroupComponent { } // @public (undocumented) -export class SiNavbarVerticalNextGroupTriggerDirective implements OnInit { +export class SiNavbarVerticalNextGroupTriggerDirective implements OnInit, OnDestroy { constructor(); // (undocumented) readonly expanded: _angular_core.WritableSignal; diff --git a/projects/element-ng/navbar-vertical-next/si-navbar-vertical-next-group-trigger.directive.ts b/projects/element-ng/navbar-vertical-next/si-navbar-vertical-next-group-trigger.directive.ts index 1166d00c30..2e43093455 100644 --- a/projects/element-ng/navbar-vertical-next/si-navbar-vertical-next-group-trigger.directive.ts +++ b/projects/element-ng/navbar-vertical-next/si-navbar-vertical-next-group-trigger.directive.ts @@ -15,6 +15,7 @@ import { Injector, input, linkedSignal, + OnDestroy, OnInit, signal, TemplateRef, @@ -53,7 +54,7 @@ class SiNavbarFlyoutAnchorComponent { '(click)': 'triggered()' } }) -export class SiNavbarVerticalNextGroupTriggerDirective implements OnInit { +export class SiNavbarVerticalNextGroupTriggerDirective implements OnInit, OnDestroy { private static idCounter = 0; /** @internal */ @@ -121,6 +122,11 @@ export class SiNavbarVerticalNextGroupTriggerDirective implements OnInit { this.attachInline(); } + ngOnDestroy(): void { + this.flyoutOutsideClickSubscription?.unsubscribe(); + this.overlayRef.dispose(); + } + /** @internal */ hideFlyout(): void { if (this.flyout()) { @@ -134,7 +140,7 @@ export class SiNavbarVerticalNextGroupTriggerDirective implements OnInit { } protected triggered(): void { - if (this.navbar.collapsed()) { + if (this.navbar.collapsed() || this.navbar.alwaysOpenGroupsInFlyout()) { this.toggleFlyout(); } else { this.expanded.set(!this.expanded()); diff --git a/projects/element-ng/navbar-vertical-next/si-navbar-vertical-next-group.component.ts b/projects/element-ng/navbar-vertical-next/si-navbar-vertical-next-group.component.ts index 91670f1d5f..fdb06e6878 100644 --- a/projects/element-ng/navbar-vertical-next/si-navbar-vertical-next-group.component.ts +++ b/projects/element-ng/navbar-vertical-next/si-navbar-vertical-next-group.component.ts @@ -20,7 +20,7 @@ import { SI_NAVBAR_VERTICAL_NEXT } from './si-navbar-vertical-next.provider'; [class.inline-group]="!flyout" [class.dropdown-menu]="flyout" [cdkTrapFocus]="flyout" - [cdkTrapFocusAutoCapture]="flyout" + [cdkTrapFocusAutoCapture]="autoCaptureFocus()" >
@@ -44,6 +44,10 @@ export class SiNavbarVerticalNextGroupComponent { // Store initial value, as the mode for an instance never changes. protected flyout = this.groupTrigger.flyout(); + protected readonly autoCaptureFocus = computed( + () => this.flyout && !this.navbar.alwaysOpenGroupsInFlyout() + ); + protected readonly visible = computed(() => { return this.flyout || (!this.navbar.collapsed() && this.groupTrigger.expanded()); }); diff --git a/projects/element-ng/navbar-vertical-next/si-navbar-vertical-next-item.component.html b/projects/element-ng/navbar-vertical-next/si-navbar-vertical-next-item.component.html index 1a8613186d..07a51c9dd7 100644 --- a/projects/element-ng/navbar-vertical-next/si-navbar-vertical-next-item.component.html +++ b/projects/element-ng/navbar-vertical-next/si-navbar-vertical-next-item.component.html @@ -18,5 +18,8 @@ > } @if (group) { -