Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(menu): clarify multiple side menu behavior #3186

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import Sides from '@site/static/usage/v7/menu/sides/index.md';

## Multiple Menus

When multiple menus exist on the same side, we need to enable the menu that we want to open before it can be opened. This can be done by calling the `enable` method on the `MenuController`. We can then call `open` on a menu based on its `menuId` or `side`.
When multiple menus exist on the same side, we need refer to them by ID instead of side. Otherwise, the wrong menu may be activated.

import Multiple from '@site/static/usage/v7/menu/multiple/index.md';

Expand Down
20 changes: 15 additions & 5 deletions static/usage/v7/menu/multiple/angular/example_component_ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,29 @@ export class ExampleComponent {
constructor(private menuCtrl: MenuController) {}

openFirstMenu() {
// Open the menu by menu-id
this.menuCtrl.enable(true, 'first-menu');
/**
* Open the menu by menu-id
* We refer to the menu using an ID
* because multiple "start" menus exist.
*/
this.menuCtrl.open('first-menu');
}

openSecondMenu() {
// Open the menu by menu-id
this.menuCtrl.enable(true, 'second-menu');
/**
* Open the menu by menu-id
* We refer to the menu using an ID
* because multiple "start" menus exist.
*/
this.menuCtrl.open('second-menu');
}

openEndMenu() {
// Open the menu by side
/**
* Open the menu by side
* We can refer to the menu by side
* here because only one "end" menu exists
*/
this.menuCtrl.open('end');
}
}
Expand Down
20 changes: 15 additions & 5 deletions static/usage/v7/menu/multiple/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,29 @@

<script>
async function openFirstMenu() {
// Open the menu by menu-id
await menuController.enable(true, 'first-menu');
/**
* Open the menu by menu-id
* We refer to the menu using an ID
* because multiple "start" menus exist.
*/
await menuController.open('first-menu');
}

async function openSecondMenu() {
// Open the menu by menu-id
await menuController.enable(true, 'second-menu');
/**
* Open the menu by menu-id
* We refer to the menu using an ID
* because multiple "start" menus exist.
*/
await menuController.open('second-menu');
}

async function openEndMenu() {
// Open the menu by side
/**
* Open the menu by side
* We can refer to the menu by side
* here because only one "end" menu exists
*/
await menuController.open('end');
}
</script>
Expand Down
20 changes: 15 additions & 5 deletions static/usage/v7/menu/multiple/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,29 @@

<script>
async function openFirstMenu() {
// Open the menu by menu-id
await menuController.enable(true, 'first-menu');
/**
* Open the menu by menu-id
* We refer to the menu using an ID
* because multiple "start" menus exist.
*/
await menuController.open('first-menu');
}

async function openSecondMenu() {
// Open the menu by menu-id
await menuController.enable(true, 'second-menu');
/**
* Open the menu by menu-id
* We refer to the menu using an ID
* because multiple "start" menus exist.
*/
await menuController.open('second-menu');
}

async function openEndMenu() {
// Open the menu by side
/**
* Open the menu by side
* We can refer to the menu by side
* here because only one "end" menu exists
*/
await menuController.open('end');
}
</script>
Expand Down
20 changes: 15 additions & 5 deletions static/usage/v7/menu/multiple/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,29 @@ import { menuController } from '@ionic/core/components';

function Example() {
async function openFirstMenu() {
// Open the menu by menu-id
await menuController.enable(true, 'first-menu');
/**
* Open the menu by menu-id
* We refer to the menu using an ID
* because multiple "start" menus exist.
*/
await menuController.open('first-menu');
}

async function openSecondMenu() {
// Open the menu by menu-id
await menuController.enable(true, 'second-menu');
/**
* Open the menu by menu-id
* We refer to the menu using an ID
* because multiple "start" menus exist.
*/
await menuController.open('second-menu');
}

async function openEndMenu() {
// Open the menu by side
/**
* Open the menu by side
* We can refer to the menu by side
* here because only one "end" menu exists
*/
await menuController.open('end');
}

Expand Down
20 changes: 15 additions & 5 deletions static/usage/v7/menu/multiple/vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,29 @@
components: { IonButton, IonContent, IonHeader, IonMenu, IonPage, IonTitle, IonToolbar, menuController },
setup() {
const openFirstMenu = async () => {
// Open the menu by menu-id
await menuController.enable(true, 'first-menu');
/**
* Open the menu by menu-id
* We refer to the menu using an ID
* because multiple "start" menus exist.
*/
await menuController.open('first-menu');
};

const openSecondMenu = async () => {
// Open the menu by menu-id
await menuController.enable(true, 'second-menu');
/**
* Open the menu by menu-id
* We refer to the menu using an ID
* because multiple "start" menus exist.
*/
await menuController.open('second-menu');
};

const openEndMenu = async () => {
// Open the menu by side
/**
* Open the menu by side
* We can refer to the menu by side
* here because only one "end" menu exists
*/
await menuController.open('end');
};

Expand Down
Loading