Skip to content

matMenuTriggerData not working with nested menu #12467

Closed
@anisabboud

Description

@anisabboud

Bug

Switching between submenus doesn't pass the [matMenuTriggerData] properly.
It passes only to the first selected submenu, but the data is empty when selecting other submenus after the first.
nestedmenu

What are the steps to reproduce?

Sample code: https://stackblitz.com/edit/angular-nevxe3?file=app%2Fnested-menu-example.html

<button mat-button [matMenuTriggerFor]="animals">Animal index</button>

<mat-menu #animals="matMenu">
  <button mat-menu-item [matMenuTriggerFor]="submenu" [matMenuTriggerData]="{category: 'vertebrates'}">Vertebrates</button>
  <button mat-menu-item [matMenuTriggerFor]="submenu" [matMenuTriggerData]="{category: 'invertebrates'}">Invertebrates</button>
</mat-menu>

<mat-menu #submenu="matMenu">
  <ng-template matMenuContent let-category="category">
    <button mat-menu-item>You selected: {{category}}</button>
  </ng-template>
</mat-menu>

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 6.1.0
Material 6.4.2

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions