Skip to content

p-menu popup breaks when appendTo="body" [popup]="true" and routerLink/navigate (overlay doesn't close) #19213

@SoyDiego

Description

@SoyDiego

Describe the bug

When the p-menu has the option appendTo="body" [popup]="true" and the item we're clicking has a routerLink or inside the command a this.router.navigate() or this.router.navigateByUrl() the popup doesn't close and it's shown in the page navigated.
In PrimeNG 20.2.0 it's working perfectly (my last version) in PrimeNG 21 it's not working

Image The first option of this menu is a routerLink, when I click it, it navigates but the menu doesn't close.

Pull Request Link

No response

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

No response

Reproducer

Environment

Angular version

21

PrimeNG version

v21

Node version

24

Browser(s)

No response

Steps to reproduce the behavior

  1. Have 2 pages with routing.
  2. Put a p-menu with appendTo="body" [popup]="true" and one item with routerLink to the other page.
  3. When Angular navigates to the other pages the menu doesn't close.

Expected behavior

Menu closes

Metadata

Metadata

Labels

Type: BugIssue contains a bug related to a specific component. Something about the component is not working

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions