Skip to content

addItem method is empty in node_modules/@angular/material/esm2015/menu.js #16753

Description

@MartinJaskulla

I updated @angular/material from 8.0.2 to 8.1.2 and my custom menu component stopped working with the keyboard.

The problem seems to be that in node_modules/@angular/material/esm2015/menu.js the addItem method is empty.

Version 8.1.2node_modules/@angular/material/esm2015/menu.js

 /*
* Registers a menu item with the menu.
* @docs-private
* @deprecated No longer being used. To be removed.
* @breaking-change 9.0.0
*/
/**
* @param {?} _item
* @return {?}
*/
addItem(_item) {}

Version 8.0.2node_modules/@angular/material/esm2015/menu.js

addItem(_item) {
if (this._items.indexOf(item) === -1) {
this._items.push(item);
this._itemChanges.next(this._items);
}
}

The code below worked before updating to 8.1.2

// MenuComponent
@ViewChild('menu', { static: false }) menu: MatMenu;
@ContentChildren(MenuItemComponent) menuItems: QueryList<
MenuItemComponent
>;
@ContentChildren(MenuItemComponent) menuItems: QueryList<
MenuItemComponent
>;
this.menuItems.forEach(menuItem => {
this.menu.addItem(menuItem.matMenuItem);
});
// MenuItemComponent
@ViewChild(MatMenuItem, {static: false}) matMenuItem: MatMenuItem
  1. Should the addItem method be empty? Is this a bug? @breaking-change 9.0.0 sounds to me that the method should be remove for @angular/material 9.0.0 and not be empty for 8.1.2

  2. How should I register my custom menu items instead?
    Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions