Skip to content

fix(menu-trigger): support mat prefix for compatibility mode #2888

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions src/lib/core/compatibility/compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const MAT_ELEMENTS_SELECTOR = `
mat-tab,
mat-tab-group,
mat-toolbar,
matMenuTriggerFor,
matTooltip`;

/** Selector that matches all elements that may have style collisions with AngularJS Material. */
Expand Down Expand Up @@ -122,6 +123,7 @@ export const MD_ELEMENTS_SELECTOR = `
md-tab,
md-tab-group,
md-toolbar,
mdMenuTriggerFor,
mdTooltip`;

/** Directive that enforces that the `mat-` prefix cannot be used. */
Expand Down
11 changes: 8 additions & 3 deletions src/lib/menu/menu-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {MenuPositionX, MenuPositionY} from './menu-positions';
* responsible for toggling the display of the provided menu instance.
*/
@Directive({
selector: '[md-menu-trigger-for], [mat-menu-trigger-for], [mdMenuTriggerFor]',
selector: `[md-menu-trigger-for], [mdMenuTriggerFor], [matMenuTriggerFor]`,
host: {
'aria-haspopup': 'true',
'(mousedown)': '_handleMousedown($event)',
Expand All @@ -51,13 +51,18 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy {
// the first item of the list when the menu is opened via the keyboard
private _openedByMouse: boolean = false;

/** References the menu instance that the trigger is associated with. */
@Input('mdMenuTriggerFor') menu: MdMenuPanel;

/** @deprecated */
@Input('md-menu-trigger-for')
get _deprecatedMenuTriggerFor(): MdMenuPanel { return this.menu; }
set _deprecatedMenuTriggerFor(v: MdMenuPanel) { this.menu = v; }

/** References the menu instance that the trigger is associated with. */
@Input('mdMenuTriggerFor') menu: MdMenuPanel;
// Property with `mat-` prefix for noconflict mode.
@Input('matMenuTriggerFor')
get _matMenuTriggerFor() { return this.menu; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add MdMenuPanel type?

set _matMenuTriggerFor(v) { this.menu = v; }

/** Event emitted when the associated menu is opened. */
@Output() onMenuOpen = new EventEmitter<void>();
Expand Down