Skip to content

Commit

Permalink
fix(material/menu): add constructor overloads for non-deprecated sign…
Browse files Browse the repository at this point in the history
…atures (#24860)

In #24116 I explored using constructor overload for deprecations, but I forgot to add an overload for the non-deprecated signatures.

Fixes #24740.

(cherry picked from commit 08851de)
  • Loading branch information
crisbeto authored and andrewseguin committed May 2, 2022
1 parent 884f760 commit 6a0e6ba
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/material/menu/menu-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ export abstract class _MatMenuContentBase implements OnDestroy {
/** Emits when the menu content has been attached. */
readonly _attached = new Subject<void>();

constructor(
template: TemplateRef<any>,
componentFactoryResolver: ComponentFactoryResolver,
appRef: ApplicationRef,
injector: Injector,
viewContainerRef: ViewContainerRef,
document: any,
changeDetectorRef: ChangeDetectorRef,
);

/**
* @deprecated `changeDetectorRef` is now a required parameter.
* @breaking-change 9.0.0
Expand Down
10 changes: 9 additions & 1 deletion src/material/menu/menu-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,16 @@ export class MatMenuItem
/** Whether the menu item acts as a trigger for a sub-menu. */
_triggersSubmenu: boolean = false;

constructor(
elementRef: ElementRef<HTMLElement>,
document: any,
focusMonitor: FocusMonitor,
parentMenu: MatMenuPanel<MatMenuItem> | undefined,
changeDetectorRef: ChangeDetectorRef,
);

/**
* @deprecated `_document`, `changeDetectorRef` and `focusMonitor` to become required.
* @deprecated `document`, `changeDetectorRef` and `focusMonitor` to become required.
* @breaking-change 12.0.0
*/
constructor(
Expand Down
12 changes: 12 additions & 0 deletions src/material/menu/menu-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ export abstract class _MatMenuTriggerBase implements AfterContentInit, OnDestroy
// tslint:disable-next-line:no-output-on-prefix
@Output() readonly onMenuClose: EventEmitter<void> = this.menuClosed;

constructor(
overlay: Overlay,
element: ElementRef<HTMLElement>,
viewContainerRef: ViewContainerRef,
scrollStrategy: any,
parentMenu: MatMenuPanel,
menuItemInstance: MatMenuItem,
dir: Directionality,
focusMonitor: FocusMonitor,
ngZone: NgZone,
);

/**
* @deprecated `focusMonitor` will become a required parameter.
* @breaking-change 8.0.0
Expand Down
18 changes: 18 additions & 0 deletions src/material/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,24 @@ export class _MatMenuBase

readonly panelId = `mat-menu-panel-${menuPanelUid++}`;

constructor(
elementRef: ElementRef<HTMLElement>,
ngZone: NgZone,
defaultOptions: MatMenuDefaultOptions,
changeDetectorRef: ChangeDetectorRef,
);

/**
* @deprecated `_changeDetectorRef` to become a required parameter.
* @breaking-change 15.0.0
*/
constructor(
elementRef: ElementRef<HTMLElement>,
ngZone: NgZone,
defaultOptions: MatMenuDefaultOptions,
changeDetectorRef?: ChangeDetectorRef,
);

constructor(
private _elementRef: ElementRef<HTMLElement>,
private _ngZone: NgZone,
Expand Down
7 changes: 6 additions & 1 deletion tools/public_api_guard/material/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export const matMenuAnimations: {

// @public
export class _MatMenuBase implements AfterContentInit, MatMenuPanel<MatMenuItem>, OnInit, OnDestroy {
constructor(_elementRef: ElementRef<HTMLElement>, _ngZone: NgZone, _defaultOptions: MatMenuDefaultOptions, _changeDetectorRef?: ChangeDetectorRef | undefined);
constructor(elementRef: ElementRef<HTMLElement>, ngZone: NgZone, defaultOptions: MatMenuDefaultOptions, changeDetectorRef: ChangeDetectorRef);
// @deprecated
constructor(elementRef: ElementRef<HTMLElement>, ngZone: NgZone, defaultOptions: MatMenuDefaultOptions, changeDetectorRef?: ChangeDetectorRef);
// (undocumented)
addItem(_item: MatMenuItem): void;
_allItems: QueryList<MatMenuItem>;
Expand Down Expand Up @@ -169,6 +171,7 @@ export class MatMenuContent extends _MatMenuContentBase {

// @public (undocumented)
export abstract class _MatMenuContentBase implements OnDestroy {
constructor(template: TemplateRef<any>, componentFactoryResolver: ComponentFactoryResolver, appRef: ApplicationRef, injector: Injector, viewContainerRef: ViewContainerRef, document: any, changeDetectorRef: ChangeDetectorRef);
// @deprecated
constructor(template: TemplateRef<any>, componentFactoryResolver: ComponentFactoryResolver, appRef: ApplicationRef, injector: Injector, viewContainerRef: ViewContainerRef, document: any, changeDetectorRef?: ChangeDetectorRef);
attach(context?: any): void;
Expand All @@ -194,6 +197,7 @@ export interface MatMenuDefaultOptions {

// @public
export class MatMenuItem extends _MatMenuItemBase implements FocusableOption, CanDisable, CanDisableRipple, AfterViewInit, OnDestroy {
constructor(elementRef: ElementRef<HTMLElement>, document: any, focusMonitor: FocusMonitor, parentMenu: MatMenuPanel<MatMenuItem> | undefined, changeDetectorRef: ChangeDetectorRef);
// @deprecated
constructor(elementRef: ElementRef<HTMLElement>, document?: any, focusMonitor?: FocusMonitor, parentMenu?: MatMenuPanel<MatMenuItem>, changeDetectorRef?: ChangeDetectorRef);
_checkDisabled(event: Event): void;
Expand Down Expand Up @@ -283,6 +287,7 @@ export class MatMenuTrigger extends _MatMenuTriggerBase {

// @public (undocumented)
export abstract class _MatMenuTriggerBase implements AfterContentInit, OnDestroy {
constructor(overlay: Overlay, element: ElementRef<HTMLElement>, viewContainerRef: ViewContainerRef, scrollStrategy: any, parentMenu: MatMenuPanel, menuItemInstance: MatMenuItem, dir: Directionality, focusMonitor: FocusMonitor, ngZone: NgZone);
// @deprecated
constructor(overlay: Overlay, element: ElementRef<HTMLElement>, viewContainerRef: ViewContainerRef, scrollStrategy: any, parentMenu: MatMenuPanel, menuItemInstance: MatMenuItem, dir: Directionality, focusMonitor?: FocusMonitor | null);
// @deprecated
Expand Down

0 comments on commit 6a0e6ba

Please sign in to comment.