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 23b85dfce..35757dcc6 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 1166d00c3..2e4309345 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 91670f1d5..fdb06e687 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 1a8613186..07a51c9dd 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) { -