Skip to content

Commit 812c1a6

Browse files
committed
Menu review
1 parent 7dbaab7 commit 812c1a6

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

  • content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/menu.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ linktitle: "Menus"
44
url: /apidocs-mxsdk/apidocs/web-extensibility-api-11/menu/
55
---
66

7-
# Menu Properties
7+
## Menu Properties
88

99
A menu has the following properties:
1010

@@ -21,19 +21,26 @@ A menu has the following properties:
2121
{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/web/menus/grouped_menus.png" width="300" >}}
2222

2323
{{% alert color="info" %}}
24-
It is important to note that a menu can only have an action or submenus. It cannot have both. A parent menu is not a clickable menu, it can only contain sub menus that are clickable or more parent menus. If you try to add both submenus and an action to a menu, the code will not compile.
24+
A menu can only have an action or sub-menus—it cannot have both. A parent menu is not a clickable menu, it can only contain sub-menus that are clickable or more parent menus. If you try to add both sub-menus and an action to a menu, the code will not compile.
2525
{{% /alert %}}
2626

27-
# Menu action payload
28-
The menu can have a context or no context. When adding a context menu to a document or an entity through our [appExplorer](/apidocs-mxsdk/apidocs/web-extensibility-api-11/app-explorer-api/) or [documents](/apidocs-mxsdk/apidocs/web-extensibility-api-11/documents-api/) APIs, Studio Pro will send the document id back to the menu, which then will invoke the action passing this document id as the argument. Which means the menu will need to be a `Menu<DocumentContext>`. So when you create the menu with this context, the action needs to have a `DocumentContext` as its argument, or the action will not receive the document id when the context menu gets clicked.
29-
**The code will not compile if your action has the wrong payload** (e.g. if you pass a number or a different object), but it is perfectly fine for your action to have no payload at all, since your context menu might not need to do anything with the ID of the document.
27+
## Menu Action Payload
28+
29+
A menu can either have a context or no context. When adding a context menu to a document or an entity through the [appExplorer](/apidocs-mxsdk/apidocs/web-extensibility-api-11/app-explorer-api/) or [documents](/apidocs-mxsdk/apidocs/web-extensibility-api-11/documents-api/) APIs, Studio Pro sends the document Id back to the menu. The menu then invokes the action and passes this document Id as the argument. Because of this, the menu must be identified as `Menu<DocumentContext>`. When you create the menu with this context, the action needs to have a `DocumentContext` argument; otherwise, the action will not receive the document Id when the context menu is clicked.
30+
31+
{{% alert="info" %}}
32+
The code will not compile if your action has the wrong payload (for example, if you pass a number or a different object). However, it is valid for your action to have no payload at all if your context menu does not need to use the document Id.
33+
{{% /alert %}}
3034

3135
The `DocumentContext` type has only one property, the `documentId` string:
36+
3237
```typescript
3338
type DocumentContext = { documentId: string };
3439
```
3540

36-
Here you can see the different ways to use menus:
41+
## Menu Usage Examples
42+
43+
Below are the different ways to use menus:
3744

3845
```typescript
3946
import { DocumentContext, IComponent, Menu, getStudioProApi } from "@mendix/extensions-api";

0 commit comments

Comments
 (0)