Skip to content

feat(navbar-vertical-next): open items in overlay menu when chip is clicked#2282

Open
mistrykaran91 wants to merge 3 commits into
mainfrom
feat/add-menu-selection-to-vertical-navbar-next
Open

feat(navbar-vertical-next): open items in overlay menu when chip is clicked#2282
mistrykaran91 wants to merge 3 commits into
mainfrom
feat/add-menu-selection-to-vertical-navbar-next

Conversation

@mistrykaran91

@mistrykaran91 mistrykaran91 commented Jul 6, 2026

Copy link
Copy Markdown
Member
  • The chip previously portalled the active root item into the chip slot and triggered it directly. It is now a button that opens an overlay menu hosting the full items container, so users can navigate to any entry while the sidebar stays parked.
  • Added SiNavbarVerticalNextChipMenuComponent to handle the chip button and menu overlay.

Documentation.
Examples.
Dashboards Demo.
Playwright report.

Coverage Reports:

Code Coverage

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the vertical navigation component to improve the collapsed chip menu behavior by using a dedicated CDK overlay and portaling the item labels and container. The review feedback advises replacing manual state propagation via effect() with a declarative linkedSignal for managing the chip menu's open state, which also allows removing an obsolete auto-close effect.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread projects/element-ng/navbar-vertical-next/si-navbar-vertical-next.component.ts Outdated
Comment thread projects/element-ng/navbar-vertical-next/si-navbar-vertical-next.component.ts Outdated
@mistrykaran91 mistrykaran91 changed the title feat(navbar-vertical-next): implement chip menu selection in vertical navbar - DO NO REVIEW feat(navbar-vertical-next): implement chip menu selection in vertical navbar - DO NOT REVIEW Jul 7, 2026
@mistrykaran91 mistrykaran91 force-pushed the feat/add-menu-selection-to-vertical-navbar-next branch from cd7f3c4 to 66f557a Compare July 7, 2026 13:27
@mistrykaran91 mistrykaran91 changed the title feat(navbar-vertical-next): implement chip menu selection in vertical navbar - DO NOT REVIEW feat(navbar-vertical-next): open items in overlay menu when chip is clicked Jul 7, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the SiNavbarVerticalNextChipMenuComponent to handle the chip button and overlay menu when the vertical navbar is in inline-collapse mode, replacing the previous DOM portal approach. Additionally, the SiNavbarVerticalNextGroupTriggerDirective was refactored to lazily create its overlay, ensuring correct DOM and accessibility tree ordering. Feedback on the changes focuses on adhering to the repository style guide by replacing manual state propagation via effect() with Angular's linkedSignal for managing the chip menu's open state.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the SiNavbarVerticalNextChipMenuComponent to manage the chip button and menu overlay in the vertical navbar's inline-collapse mode, refactoring related styles, layout constants, and group trigger logic while adding comprehensive tests. Feedback on the changes suggests replacing an effect() in SiNavbarVerticalNextItemComponent with a computed() signal to adhere to the style guide and simplify the component by removing its constructor. Additionally, it is recommended to call this.detachFlyout() on destruction and wrap browser-dependent CDK overlay operations in an isPlatformBrowser check within SiNavbarVerticalNextGroupTriggerDirective to prevent memory leaks and SSR issues.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 150 to 153
this.destroyRef.onDestroy(() => {
this.overlayRef.detach();
this.overlayRef.dispose();
this.overlayRef?.detach();
this.overlayRef?.dispose();
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To prevent potential memory leaks and ensure proper cleanup of the flyout anchor component and outside click subscription, we should call this.detachFlyout() inside the onDestroy hook. Additionally, since Angular CDK Overlay is a browser-dependent UI feature, ensure these operations are only executed in a browser environment using isPlatformBrowser to prevent errors during Server-Side Rendering (SSR).

    if (isPlatformBrowser(this.platformId)) {
      this.destroyRef.onDestroy(() => {
        this.detachFlyout();
        this.overlayRef?.detach();
        this.overlayRef?.dispose();
      });
    }
References
  1. When using browser-dependent UI features like Angular CDK Overlay, ensure they are only executed in a browser environment. Use a check like isPlatformBrowser to prevent errors during Server-Side Rendering (SSR).

…licked

- The chip previously portalled the active root item into the chip slot and triggered it directly. It is now a button that opens an overlay menu hosting the full items container, so users can navigate to any entry while the sidebar stays parked.
- Added `SiNavbarVerticalNextChipMenuComponent` to handle the chip button and menu overlay.
@mistrykaran91 mistrykaran91 force-pushed the feat/add-menu-selection-to-vertical-navbar-next branch from 3a95a75 to e210f17 Compare July 8, 2026 08:51
@mistrykaran91 mistrykaran91 marked this pull request as ready for review July 8, 2026 09:10
@mistrykaran91 mistrykaran91 requested review from a team as code owners July 8, 2026 09:10
@mistrykaran91

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the SiNavbarVerticalNextChipMenuComponent to support a chip button and menu overlay for the vertical navbar in inline-collapse mode, utilizing CDK portals to relocate the items container. It also refactors the group trigger directive to lazily create its overlay for correct accessibility tree ordering, updates SCSS layouts, and adds comprehensive unit and E2E tests. A critical issue was identified in SiNavbarVerticalNextItemComponent where using viewChild.required for itemTitleEl can cause a runtime crash (NG0951) during initial change detection; it is recommended to use an optional viewChild and handle the undefined state gracefully.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +86 to +94
private readonly itemTitleEl = viewChild.required<ElementRef<HTMLElement>>('itemTitleEl');

/** Signal mirror of the navbar's chip mode. `true` when inline-collapse is active and the navbar is collapsed.
/**
* Text label of this item, derived from the projected `<ng-content>`.
* Consumed by the chip button to mirror the active item's label without
* duplicating markup.
* @internal
*/
readonly chipMode = computed(() => this.navbar.chipMode());
readonly label = computed(() => this.itemTitleEl().nativeElement.textContent?.trim() ?? '');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using viewChild.required for itemTitleEl can cause a runtime crash (NG0951: Child query [required view child] is not yet available.) during the initial change detection. This happens because si-navbar-vertical-next-chip-menu is declared before <ng-content> in the parent template, meaning the active item's view is not yet initialized when the chip menu evaluates item.label().

To prevent this, use an optional viewChild and handle the undefined state gracefully in the computed signal. Once the view initializes, the signal will automatically update with the correct text. Additionally, ensure that you trim the textContent to remove formatting whitespace.

Suggested change
private readonly itemTitleEl = viewChild.required<ElementRef<HTMLElement>>('itemTitleEl');
/** Signal mirror of the navbar's chip mode. `true` when inline-collapse is active and the navbar is collapsed.
/**
* Text label of this item, derived from the projected `<ng-content>`.
* Consumed by the chip button to mirror the active item's label without
* duplicating markup.
* @internal
*/
readonly chipMode = computed(() => this.navbar.chipMode());
readonly label = computed(() => this.itemTitleEl().nativeElement.textContent?.trim() ?? '');
private readonly itemTitleEl = viewChild<ElementRef<HTMLElement>>('itemTitleEl');
/**
* Text label of this item, derived from the projected <ng-content>.
* Consumed by the chip button to mirror the active item's label without
* duplicating markup.
* @internal
*/
readonly label = computed(() => this.itemTitleEl()?.nativeElement.textContent?.trim() ?? '');
References
  1. When reading text content from an ElementRef, trim the textContent to remove formatting whitespace.

@spike-rabbit spike-rabbit added this to the 51.x milestone Jul 8, 2026

@panch1739 panch1739 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mistrykaran91 Awesome!

I think there is a small delay for the Section title...it loads later than the content

Screen.Recording.2026-07-09.at.09.55.44.mov

And another small thing, unrelated to the menu...there is a small bug in Safari. It seems that the expand/collapsed is attached to the selected item instead of having a small gap:

Example safari:

Image

Example Chrome

Image

@mistrykaran91

Copy link
Copy Markdown
Member Author

Safari

Related to delay, I'm reusing the same animation which we have for when have an expanded view. I'll take a look into the other issue, related to gap in safari

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants