Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(CdkMenuTriggerFor): CdkMenuTrigger doesn't work correctly with Angular without Zone #28984

Closed
1 task
manng2 opened this issue May 1, 2024 · 2 comments
Closed
1 task
Labels
needs triage This issue needs to be triaged by the team

Comments

@manng2
Copy link

manng2 commented May 1, 2024

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

I am trying to convert my app to a Zoneless Angular application. Since converting the application to zoneless, some Angular CDK features don't work as I expected.

I fixed the OverlayRef by calling updatePosition and it works well but I can't find out how to fix the CdkMenuTriggerFor. When I open the menu, the menu list items appear at the top-left (doesn't stick to the cdkMenuTriggerFor). My code is below

<div [cdkMenuTriggerFor]="menu" class="flex items-center cursor-pointer">
  <img
    src="assets/images/default-ava.png"
    alt="Default Avatar"
    class="desktop:w-12 desktop:h-12 mobile:w-8 mobile:h-8 mr-2"
  />
</div>
<ng-template #menu>
  <app-menu cdkMenu>
    <app-menu-item cdkMenuItem class="mobile:block desktop:hidden">{{ userDetails()?.name }}</app-menu-item>
    <app-menu-item cdkMenuItem (click)="viewProfile()">Profile</app-menu-item>
    <app-menu-item cdkMenuItem (click)="logout()">Log out</app-menu-item>
  </app-menu>
</ng-template>

Reproduction

GitHub repository: https://github.com/manng2/angular-zoneless-bug-reproduce

Angular with Zone
image

Angular without Zone
image

Expected Behavior

The menu list should be attached to a parent element like Angular with Zone

Actual Behavior

The menu list appears at the top-left (don't attach to the parent element)

Environment

  • Angular: 17.0.0
  • CDK/Material: 17.0.0
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS
@manng2 manng2 added the needs triage This issue needs to be triaged by the team label May 1, 2024
@crisbeto
Copy link
Member

crisbeto commented May 1, 2024

There have been a lot of zoneless fixes after v17. Can you try updating to one of the v18 next versions?

@crisbeto
Copy link
Member

crisbeto commented May 6, 2024

Closing since there hasn't been any response since the previous comment.

@crisbeto crisbeto closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

2 participants