Search code examples
iosangularcordovaionic-frameworkion-menu

Have ion-menu closed by default on high resolution | Angular & Ionic 4


I'm making an app for iOS devices, both tablet and smartphone. I want to have the menu closed, the user will decide when to open it.

On iPad Air and iPhone the menu it's correctly displayed, but when I launch the app on iPad Pro, the resolution is too high and the menu is always visible.

iPad pro (the menu is open automatically):

enter image description here

iPad Air and iPhone (the menu is correctly closed on start):

enter image description here

So my menu code:

  <ion-split-pane class="actionApp">
  <ion-menu side="start">  
      <ion-header>
        <ion-toolbar>
          <ion-title>Menu</ion-title>
        </ion-toolbar>
      </ion-header>
      <ion-content>
        <ion-list>
          <ion-item (click)="goToPage('/homepage')">
            <ion-icon name="home" slot="start"></ion-icon>
            <ion-label>Home</ion-label>
          </ion-item>
          <ion-item>
            <ion-icon name="person" slot="start"></ion-icon>
            <ion-label>Profile</ion-label>
          </ion-item>
          <ion-item>
            <ion-icon name="chatbubbles" slot="start"></ion-icon>
            <ion-label>Messages</ion-label>
          </ion-item>
          <ion-item>
            <ion-icon name="settings" slot="start"></ion-icon>
            <ion-label>Settings</ion-label>
          </ion-item>
        </ion-list>
      </ion-content>
    </ion-menu>
<!-- <div class="loading">
  <ion-progress-bar class="loading-background" color="light" type="indeterminate"></ion-progress-bar>
</div> -->
<ion-router-outlet main></ion-router-outlet>    

How can have the menu closed? Thanks


Solution

  • You have to remove the <ion-split-pane> tag. From the docs:

    A split pane is useful when creating multi-view layouts. It allows UI elements, like menus, to be displayed as the viewport width increases.

    Link to ion-split-pane docs