Components: Specific position for MdMenu

Created on 10 Jan 2017  路  2Comments  路  Source: angular/components

Bug, feature request, or proposal:

Feature

What is the expected behavior?

It might be useful to set explicitly the position of the MdMenu by using real x and y coordinates.

What is the current behavior?

When you open the menu programmatically via the ViewChild you can only set for position "above" and "below" respectively "before" and "after"

What is the use-case or motivation for changing an existing behavior?

I have a svg with several paths. When I click on one of these paths I'd like to show a Menu with actions. I have to call it programmatically. I assigned the mdMenuTriggerFor on a hidden input field. But now the menu will always be displayed on the top left corner.

Which versions of Angular, Material, OS, browsers are affected?

Material: 2.0.0-beta.1
OS: Microsoft Windows [Version 6.1.7601]
Browser: Chrome Version 55.0.2883.87 m

P5 materiamenu feature

Most helpful comment

@arlowhite I've come up with a work-around for the time being that works fairly well. I've added an ngStyle to an invisible, absolutley positioned trigger that updates the top and left based on mouse click.

All 2 comments

I would like this option too. There are many cases where you would want to show a menu at different locations in response to a click event.

  • Right-click table cell or column to show a menu.
  • Right-click chart to show options.

This feature also means that you should be able to create a MdMenu without an associated MdMenuTrigger. Or, at least you should be able to create a MdMenu without a trigger and specify a single-use trigger via the API:

this.menu.openAtElement(event.target)

@arlowhite I've come up with a work-around for the time being that works fairly well. I've added an ngStyle to an invisible, absolutley positioned trigger that updates the top and left based on mouse click.

Was this page helpful?
0 / 5 - 0 ratings