Skip to content

Commit 9bb09eb

Browse files
devversionmmalerba
authored andcommitted
chore: fix mdc-menu prototype not working with ivy
Currently the `MatMenu` from the `@angular/material-experimental/mdc-menu` entry-point does not with Ivy as the base class (`MatMenu`) is not decorated and therefore Ivy is not able to generate the proper factory for the constructor. In order to fix this, we just create a pass-through constructor which ensures that dendency injection properly works.
1 parent 4247303 commit 9bb09eb

File tree

1 file changed

+20
-3
lines changed
  • src/material-experimental/mdc-menu

1 file changed

+20
-3
lines changed

src/material-experimental/mdc-menu/menu.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,23 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {ChangeDetectionStrategy, Component, ViewEncapsulation, Provider} from '@angular/core';
109
import {Overlay, ScrollStrategy} from '@angular/cdk/overlay';
1110
import {
12-
MatMenu as BaseMatMenu,
11+
ChangeDetectionStrategy,
12+
Component,
13+
ElementRef,
14+
Inject,
15+
NgZone,
16+
Provider,
17+
ViewEncapsulation
18+
} from '@angular/core';
19+
import {
20+
MAT_MENU_DEFAULT_OPTIONS,
1321
MAT_MENU_PANEL,
14-
matMenuAnimations,
1522
MAT_MENU_SCROLL_STRATEGY,
23+
MatMenu as BaseMatMenu,
24+
matMenuAnimations,
25+
MatMenuDefaultOptions,
1626
} from '@angular/material/menu';
1727

1828
/** @docs-private */
@@ -45,6 +55,13 @@ export const MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER: Provider = {
4555
]
4656
})
4757
export class MatMenu extends BaseMatMenu {
58+
59+
constructor(_elementRef: ElementRef<HTMLElement>,
60+
_ngZone: NgZone,
61+
@Inject(MAT_MENU_DEFAULT_OPTIONS) _defaultOptions: MatMenuDefaultOptions) {
62+
super(_elementRef, _ngZone, _defaultOptions);
63+
}
64+
4865
setElevation(_depth: number) {
4966
// TODO(crisbeto): MDC's styles come with elevation already and we haven't mapped our mixins
5067
// to theirs. Disable the elevation stacking for now until everything has been mapped.

0 commit comments

Comments
 (0)