Skip to content

Commit 1e392de

Browse files
authored
docs(menu): clarify multiple side menu behavior (#3186)
1 parent 60e1778 commit 1e392de

File tree

6 files changed

+76
-26
lines changed

6 files changed

+76
-26
lines changed

docs/api/menu.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import Sides from '@site/static/usage/v7/menu/sides/index.md';
6060

6161
## Multiple Menus
6262

63-
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`.
63+
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.
6464

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

static/usage/v7/menu/multiple/angular/example_component_ts.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,29 @@ export class ExampleComponent {
1010
constructor(private menuCtrl: MenuController) {}
1111

1212
openFirstMenu() {
13-
// Open the menu by menu-id
14-
this.menuCtrl.enable(true, 'first-menu');
13+
/**
14+
* Open the menu by menu-id
15+
* We refer to the menu using an ID
16+
* because multiple "start" menus exist.
17+
*/
1518
this.menuCtrl.open('first-menu');
1619
}
1720

1821
openSecondMenu() {
19-
// Open the menu by menu-id
20-
this.menuCtrl.enable(true, 'second-menu');
22+
/**
23+
* Open the menu by menu-id
24+
* We refer to the menu using an ID
25+
* because multiple "start" menus exist.
26+
*/
2127
this.menuCtrl.open('second-menu');
2228
}
2329

2430
openEndMenu() {
25-
// Open the menu by side
31+
/**
32+
* Open the menu by side
33+
* We can refer to the menu by side
34+
* here because only one "end" menu exists
35+
*/
2636
this.menuCtrl.open('end');
2737
}
2838
}

static/usage/v7/menu/multiple/demo.html

+15-5
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,29 @@
6262

6363
<script>
6464
async function openFirstMenu() {
65-
// Open the menu by menu-id
66-
await menuController.enable(true, 'first-menu');
65+
/**
66+
* Open the menu by menu-id
67+
* We refer to the menu using an ID
68+
* because multiple "start" menus exist.
69+
*/
6770
await menuController.open('first-menu');
6871
}
6972

7073
async function openSecondMenu() {
71-
// Open the menu by menu-id
72-
await menuController.enable(true, 'second-menu');
74+
/**
75+
* Open the menu by menu-id
76+
* We refer to the menu using an ID
77+
* because multiple "start" menus exist.
78+
*/
7379
await menuController.open('second-menu');
7480
}
7581

7682
async function openEndMenu() {
77-
// Open the menu by side
83+
/**
84+
* Open the menu by side
85+
* We can refer to the menu by side
86+
* here because only one "end" menu exists
87+
*/
7888
await menuController.open('end');
7989
}
8090
</script>

static/usage/v7/menu/multiple/javascript.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,29 @@
4343

4444
<script>
4545
async function openFirstMenu() {
46-
// Open the menu by menu-id
47-
await menuController.enable(true, 'first-menu');
46+
/**
47+
* Open the menu by menu-id
48+
* We refer to the menu using an ID
49+
* because multiple "start" menus exist.
50+
*/
4851
await menuController.open('first-menu');
4952
}
5053
5154
async function openSecondMenu() {
52-
// Open the menu by menu-id
53-
await menuController.enable(true, 'second-menu');
55+
/**
56+
* Open the menu by menu-id
57+
* We refer to the menu using an ID
58+
* because multiple "start" menus exist.
59+
*/
5460
await menuController.open('second-menu');
5561
}
5662
5763
async function openEndMenu() {
58-
// Open the menu by side
64+
/**
65+
* Open the menu by side
66+
* We can refer to the menu by side
67+
* here because only one "end" menu exists
68+
*/
5969
await menuController.open('end');
6070
}
6171
</script>

static/usage/v7/menu/multiple/react.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,29 @@ import { menuController } from '@ionic/core/components';
55

66
function Example() {
77
async function openFirstMenu() {
8-
// Open the menu by menu-id
9-
await menuController.enable(true, 'first-menu');
8+
/**
9+
* Open the menu by menu-id
10+
* We refer to the menu using an ID
11+
* because multiple "start" menus exist.
12+
*/
1013
await menuController.open('first-menu');
1114
}
1215

1316
async function openSecondMenu() {
14-
// Open the menu by menu-id
15-
await menuController.enable(true, 'second-menu');
17+
/**
18+
* Open the menu by menu-id
19+
* We refer to the menu using an ID
20+
* because multiple "start" menus exist.
21+
*/
1622
await menuController.open('second-menu');
1723
}
1824

1925
async function openEndMenu() {
20-
// Open the menu by side
26+
/**
27+
* Open the menu by side
28+
* We can refer to the menu by side
29+
* here because only one "end" menu exists
30+
*/
2131
await menuController.open('end');
2232
}
2333

static/usage/v7/menu/multiple/vue.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,29 @@
5151
components: { IonButton, IonContent, IonHeader, IonMenu, IonPage, IonTitle, IonToolbar, menuController },
5252
setup() {
5353
const openFirstMenu = async () => {
54-
// Open the menu by menu-id
55-
await menuController.enable(true, 'first-menu');
54+
/**
55+
* Open the menu by menu-id
56+
* We refer to the menu using an ID
57+
* because multiple "start" menus exist.
58+
*/
5659
await menuController.open('first-menu');
5760
};
5861
5962
const openSecondMenu = async () => {
60-
// Open the menu by menu-id
61-
await menuController.enable(true, 'second-menu');
63+
/**
64+
* Open the menu by menu-id
65+
* We refer to the menu using an ID
66+
* because multiple "start" menus exist.
67+
*/
6268
await menuController.open('second-menu');
6369
};
6470
6571
const openEndMenu = async () => {
66-
// Open the menu by side
72+
/**
73+
* Open the menu by side
74+
* We can refer to the menu by side
75+
* here because only one "end" menu exists
76+
*/
6777
await menuController.open('end');
6878
};
6979

0 commit comments

Comments
 (0)