angular / angular/components

bug(cdkMenu): menu template context is not updated when cdkMenuTriggerData is changed

Open
#26,256 10 comments 11 reactions 0 assignees View on GitHub
area: cdk/menu P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### 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

When cdkMenuTriggerData is used to pass additional context to a menu template the template context is not update when the data is changed.

### Reproduction
[GitHub](https://github.com/ghostlytalamaur/angular-cdk-menu-data-bug)
[StackBlitz](https://stackblitz.com/edit/angular-s5r2am-ax9zgm?file=src/main.ts)
Steps to reproduce:
1. Open the application.
2. Click the button "Click Me!". Menu with initial counter value is shown.
3. Click "Increment" button.
4. Click "Click Me!" button second time

### Expected Behavior

Counter value in the context menu should be in sync with the value on the "Click Me!" button.

### Actual Behavior

Counter value in the context menu keep initial value and is not updated when context changes.

### Environment

- Angular: 15.0.0
- CDK/Material: 15.0.2

Contributor guide

Open the contributing guide

Research direction

Start with the linked GitHub or StackBlitz reproduction and trace how cdkMenuTriggerData reaches the Angular CDK menu template. Reproduce the stale counter after changing the value, then verify that reopening the menu shows the current counter value and that the relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.