Skip to content

md-menu not opening #4858

@summersz

Description

@summersz

Hi,

I have tried using a menu using the example code below but the menu is not opening. The open attribute is getting added to the md-menu element but no changes are happening to the md-menu-item elements.

I am finding the same for the interactive demo here:
material-web-catalog--pr4800-cl-560838193-etijdmvw.web.app/components/menu/

<span style="position: relative">
  <md-filled-button id="usage-anchor">Set with idref</md-filled-button>
  <!-- This example uses an ID reference -->
  <md-menu id="usage-menu" anchor="usage-anchor">
    <md-menu-item headline="Apple"></md-menu-item>
    <md-menu-item headline="Banana"></md-menu-item>
    <md-menu-item headline="Cucumber"></md-menu-item>
  </md-menu>
</span>

<span style="position: relative">
  <md-filled-button id="usage-anchor-2">Set with element ref</md-filled-button>
  <!-- This example uses an ID reference -->
  <md-menu id="usage-menu-2">
    <md-menu-item headline="Apple"></md-menu-item>
    <md-menu-item headline="Banana"></md-menu-item>
    <md-menu-item headline="Cucumber"></md-menu-item>
  </md-menu>
</span>

<script type="module">
  const anchorEl1 = document.body.querySelector('#usage-anchor');
  const menuEl1 = document.body.querySelector('#usage-menu');
  const anchorEl2 = document.body.querySelector('#usage-anchor-2');
  const menuEl2 = document.body.querySelector('#usage-menu-2');
  menuEl2.anchorElement = anchorEl2;
  anchorEl1.addEventListener('click', () => { menuEl1.show(); });
  anchorEl2.addEventListener('click', () => { menuEl2.show(); });
</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions