click
Description
fires on clicking a menu item or outside the menuParameters
- ev - event object
- context - object for which menu was called, optional
- action - object of selected menu item, empty if menu was closed by an outside click
- ev - native html event
Example
<script>
let menu1 = null;
let message = "";
function clicked(ev){
const action = ev.action;
message = action ? `clicked on ${action.id}` : "closed";
menu1 = null;
}
</script>
<div>{message}</div>
<div>
<Button type="primary" onclick={ev => menu1 = ev.target}>Click me (bottom menu)</Button>
{#if menu1}
<Portal>
<Menu {options} parent={menu1} onsome={clicked}></Menu>
</Portal>
{/if}
</div>
Details
You can get an object of the clicked option inside the event as in the above example. The detail property of the event will contain an object related to the clicked menu item. When a user clicks outside the menu, the ev.action
of the generated click event will be null.
Related article: Catching the change of a clicked option