question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Menu: must have a "content" element to listen for drag events on.

See original GitHub issue

Bug Report

Ionic version: [x] 5.x

Current behavior: Creating a Vue component with the ion-menu ui component results in above error. Below code is from my Home.vue, which is embedded in App.vue, which has the ion-app enclosing tags.

Expected behavior: The ionic-menu component would be displaying and clickable.

Steps to reproduce: Unsure. I have different test applications with ion-menu, and neither of them work.

Related code:

        <template>
          <ion-page>
        
              <ion-header>
                <ion-toolbar>
                  <ion-buttons slot="start">
                    <ion-menu-button
                      auto-hide="false"
                      menu="testmenu"
                    ></ion-menu-button>
                  </ion-buttons>
                </ion-toolbar>
              </ion-header>
        
              <ion-menu menu-id="testmenu" content-id="mycontent">
                <ion-content>
                  <ion-list>
                    <ion-item type="button">
                      <ion-label>Pokémon Yellow</ion-label>
                    </ion-item>
                  </ion-list>
                </ion-content>
              </ion-menu>
        
              <ion-content id="mycontent"> Router Outlet </ion-content>
        
          </ion-page>
        </template>

        <script>
        import {
          IonToolbar,
          IonMenuButton,
          IonButtons,
          IonList,
          IonItem,
          IonMenu,
          IonLabel,
          IonContent,
          IonHeader,
          IonPage
        } from "@ionic/vue";
        import { defineComponent } from "vue";
        
        export default defineComponent({
          name: "App",
          components: {
            IonToolbar,
            IonMenuButton,
            IonButtons,
            IonList,
            IonItem,
            IonMenu,
            IonLabel,
            IonContent,
            IonHeader,
            IonPage
          },
        });
        </script>
        
        <style scoped >
        </style>

Other information: I have also tried the latest LTS version of node (14.x) with the latest npm, without any result.

Ionic:

   Ionic CLI       : 6.13.1 (/home/hans/.nvm/versions/node/v15.8.0/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/vue 5.5.4

Capacitor:

   Capacitor CLI   : 2.4.6
   @capacitor/core : 2.4.6

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v15.8.0 (/home/hans/.nvm/versions/node/v15.8.0/bin/node)
   npm    : 7.5.1
   OS     : Linux 5.8


Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
liamdebeasicommented, Mar 11, 2021

Thanks! The issue is here:

const app = createApp(App)
  .use(IonicVue)
  
  app.mount('#app');

There seems to be some quirk with Vue 3 where mounting an app with Web Components too quickly causes issues. The reason why you are getting this error is Vue 3 is mounting <ion-menu content-id="mycontent"> as <ion-menu contentid="mycontent"> (note the missing - in contentid).

Normally waiting for the router to initialize first resolves the issue, but since you are not using the router you should try a requestAnimationFrame.

Can you try the following and let me know if it resolves the issue?

const app = createApp(App)
  .use(IonicVue)

requestAnimationFrame(() => {
  app.mount('#app');
});
0reactions
ionitron-bot[bot]commented, Apr 10, 2021

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Menu: must have a 'content' element to listen for drag events ...
It works fine with one exception: when the page loads, there is the following error on the console: Error: "Menu: must have a...
Read more >
Menu: must have a "content" element to listen for drag events ...
bug(v4-menu): Menu: must have a "content" element to listen for drag events on. Issue #15536 · ionic-team/ionic-framework · GitHub.
Read more >
Menu: must have a “content” element to listen for drag events on
I created a menu component which has the menu-button and the ion-menu inside because i want to use this component on multiple pages....
Read more >
Menu: must have a content'' element to listen for drag events on ...
Menu : must have a "content" element to listen for drag events on. import React from 'react'; import { IonMenu, IonHeader, IonToolbar, IonTitle,...
Read more >
Making a Menu Work in Ionic 4 - Damir's Corner
Menu : must have a "content" element to listen for drag events on. It seemed to be related to opening the menu using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found