material icon indicating copy to clipboard operation
material copied to clipboard

<md-button> throws an error when used inside <md-menu-bar>

Open cmacdonnacha opened this issue 10 years ago • 11 comments

Here's a code pen. Look at the console window on your browser to see the error.

Issue does not occur when using "button", only occurs when using "md-button". Issue does not occur if I remove "md-menu-bar" and just use "md-menu".

This error is thrown in the console window:

TypeError: Cannot read property 'setAttribute' of null
    at https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js:14:114
    at Object.forEach (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js:340:20)
    at Object.compile (https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-    material.min.js:13:31950)
    at applyDirectivesToNode (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js:8121:32)
    at compileNodes (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js:7654:15)
    at compileNodes (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js:7666:15)
    at compileNodes (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js:7666:15)
    at compile (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js:7553:15)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js:1681:11
    at Scope.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js:16052:28) <md-    menu-bar role="menubar">

cmacdonnacha avatar Jan 21 '16 15:01 cmacdonnacha

@rschmukler - Can you explain why mbButton is not supported as child on <md-menu>; yet it is supported as a child of <md-menu-item>?

I think this needs to be documented also.

ThomasBurleson avatar Jan 22 '16 05:01 ThomasBurleson

A workaround for the time being is to use - <button class="md-button" ...

shairez avatar Feb 03 '16 20:02 shairez

I have the same error, only it happens in 'md-menu-bar -> md-menu -> md-button'.

Thanks for the temporary solution.

dpatinor avatar Feb 15 '16 16:02 dpatinor

I have the same error, but the workaround suggested by @shairez breaks the css style.

kkatzer avatar Feb 25 '16 20:02 kkatzer

Same issue here!

Miguelme avatar Mar 10 '16 02:03 Miguelme

Same Issue

arjundas avatar Mar 16 '16 12:03 arjundas

+1

homerjam avatar Mar 29 '16 16:03 homerjam

+1

bobmcallan avatar Mar 30 '16 12:03 bobmcallan

I have the same issue. What I want to do is to hide the menu when clicked.

stidiovip avatar Apr 04 '16 08:04 stidiovip

I have this issue as well. I found that wrapping your <md-button> in an <a> solves the console error and maintains the appropriate styles. It's not semantic, but hopefully it will hold people over until a proper fix can be implemented.

<a>
  <md-button class="md-icon-button"
                     ng-click="$mdOpenMenu()">
  <md-icon md-svg-src=""></md-icon>
  </md-button>
</a>

chrisconover avatar Apr 25 '16 18:04 chrisconover

This issue is closed as part of our ‘Surge Focus on Material 2' efforts. For details, see our forum posting @ http://bit.ly/1UhZyWs.

ThomasBurleson avatar Jun 02 '16 07:06 ThomasBurleson