Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(material/menu): add constructor overloads for non-deprecated signatures #24860

Merged
merged 1 commit into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -196,6 +196,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