Skip to content

Commit 38b4b53

Browse files
yanisslavmihaela-lukanovadimodi
authored
docs(menu): add showon and hide article (#1589)
* docs(menu): add showon and hide article * Update components/menu/overview.md Co-authored-by: Mihaela Lukanova <[email protected]> * Update components/menu/overview.md Co-authored-by: Mihaela Lukanova <[email protected]> * Update components/menu/overview.md Co-authored-by: Mihaela Lukanova <[email protected]> * Update components/menu/show-hide-events.md Co-authored-by: Mihaela Lukanova <[email protected]> * Update components/menu/show-hide-events.md Co-authored-by: Mihaela Lukanova <[email protected]> * Update components/menu/show-hide-events.md Co-authored-by: Mihaela Lukanova <[email protected]> * Update components/menu/show-hide-events.md Co-authored-by: Mihaela Lukanova <[email protected]> * Update components/menu/show-hide-events.md Co-authored-by: Mihaela Lukanova <[email protected]> * Update components/menu/show-hide-events.md Co-authored-by: Mihaela Lukanova <[email protected]> * Update components/menu/show-hide-events.md Co-authored-by: Mihaela Lukanova <[email protected]> * Update components/menu/show-hide-events.md Co-authored-by: Mihaela Lukanova <[email protected]> * Update components/menu/show-hide-events.md Co-authored-by: Mihaela Lukanova <[email protected]> * Update components/menu/show-hide-events.md Co-authored-by: Mihaela Lukanova <[email protected]> * chore: applying suggested changes * chore: fix broken slug * Update components/menu/overview.md * Update components/menu/overview.md * Update components/menu/show-hide-behavior.md * Update components/menu/show-hide-behavior.md * docs(menu): PR polishing --------- Co-authored-by: Mihaela Lukanova <[email protected]> Co-authored-by: Dimo Dimov <[email protected]>
1 parent 90546e6 commit 38b4b53

File tree

3 files changed

+144
-2
lines changed

3 files changed

+144
-2
lines changed

components/menu/overview.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ A menu is often used to list pages, views, or sections in an application so the
102102

103103
The Blazor Menu allows you to control its orientation and display the items horizontally or vertically. [Read more about the Blazor Menu orientation...]({%slug components/menu/orientation%})
104104

105+
## Show and Hide Behavior
106+
107+
By default, the Menu child items are displayed on mouse hover over the parent item and hidden on mouse leave. You can configure the Menu to [show and hide child items by clicking or tapping the parent]({%slug menu-show-hide-behavior%}).
108+
105109
## Templates
106110

107111
You can use the functionality of the built-in templates and customize what is rendered in the items. [Read more about the Blazor Menu templates...]({%slug components/menu/templates%})
@@ -121,7 +125,9 @@ The following table lists Context Menu parameters, which are not related to othe
121125
| Attribute | Type and Default&nbsp;Value | Description |
122126
| --- | --- | --- |
123127
| `Class` | `string` | Renders additional CSS class to the main wrapping element of the component. Use it to apply custom styles or [override the theme]({%slug themes-override%}). |
124-
| `CloseOnClick` - `bool` | Determines whether the Menu popups should close when they are clicked.
128+
| `CloseOnClick` | `bool` | Determines whether the Menu popups should close when they are clicked.
129+
| `ShowOn` | `MenuShowEvent` enum <br /> (`MouseEnter`) | The browser event that will trigger child Menu items to show (mouse enter or click). |
130+
| `HideOn` | `MenuHideEvent` enum <br /> (`MouseLeave`) | The browser event that will trigger child Menu items to hide (mouse leave or click).
125131

126132

127133
## Next Steps

components/menu/show-hide-behavior.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
title: Show and Hide Behavior
3+
page_title: Menu - Show and Hide Behavior
4+
description: Configure the Menu's sub-items appearance by using the ShowOn parameter and control how they disappear through the HideOn option.
5+
slug: menu-show-hide-behavior
6+
tags: telerik,blazor,menu,show,hide,events,hover,click,mouseleave,mouseenter
7+
published: true
8+
position: 3
9+
---
10+
11+
# Show and Hide Behavior
12+
13+
You can control the user interaction with the Menu items by defining how the child items show and hide.
14+
15+
The `ShownOn` and `HideOn` parameters allow you to set the event that will show and hide the child Menu items.
16+
17+
* The `ShowOn` parameter accepts a value from the `Telerik.Blazor.MenuShowEvent` enum:
18+
19+
* `MouseEnter`&mdash;Child Menu items will display when the mouse cursor enters a parent Menu item.
20+
* `Click`&mdash;Child Menu items will display when the user clicks or taps on a parent Menu item.
21+
22+
* The `HideOn` parameter accepts a value from the `Telerik.Blazor.MenuHideEvent` enum:
23+
24+
* `MouseLeave`&mdash;Child Menu items will disappear when the mouse cursor leaves the child item group and their parent.
25+
* `Click`&mdash;Child Menu items will disappear when the user clicks or taps on their parent or on another parent, or outside the Menu. Clicking a child item will not close the currently open child item group. To change this behavior, use the [`CloseOnClick`]({%slug components/menu/overview%}#menu-parameters) parameter.
26+
27+
By default, the Menu items are shown on hover (mouse enter) over the Menu and hidden on mouse leave.
28+
29+
> Changing the `ShowOn` & `HideOn` values dynamically at runtime is not supported at this stage.
30+
>
31+
> Mixing the two behaviors is likely to produce undesired UX and is not recommended.
32+
33+
>caption Explore the show and hide behavior of the Menu items
34+
35+
````CSHTML
36+
@* Setting `ShowOn` and `HideOn` is not mandatory. The default values are `MenuShowEvent.MouseEnter` & `MenuHideEvent.MouseLeave`. *@
37+
38+
<div>
39+
<div style="padding: 20px; margin:2rem">
40+
<p>Menu <strong>ShowOn: Click</strong> : <strong>HideOn: Click</strong></p>
41+
<TelerikMenu Data="@MenuItems"
42+
ShowOn="@MenuShowEvent.Click"
43+
HideOn="@MenuHideEvent.Click" />
44+
</div>
45+
<div style="padding: 20px; margin:2rem">
46+
<p>Menu <strong>ShowOn: MouseEnter</strong> : <strong>HideOn: MouseLeave</strong></p>
47+
<TelerikMenu Data="@MenuItems"
48+
ShowOn="@MenuShowEvent.MouseEnter"
49+
HideOn="@MenuHideEvent.MouseLeave" />
50+
</div>
51+
</div>
52+
53+
@code {
54+
private List<MenuItem> MenuItems { get; set; }
55+
56+
protected override void OnInitialized()
57+
{
58+
MenuItems = new List<MenuItem>()
59+
{
60+
new MenuItem()
61+
{
62+
Text = "item 1",
63+
Items = new List<MenuItem>()
64+
{
65+
new MenuItem()
66+
{
67+
Text = "item 1.1",
68+
},
69+
new MenuItem()
70+
{
71+
Text = "item 1.2",
72+
Items = new List<MenuItem>()
73+
{
74+
new MenuItem()
75+
{
76+
Text = "item 1.2.1",
77+
},
78+
new MenuItem()
79+
{
80+
Text = "item 1.2.2",
81+
}
82+
}
83+
},
84+
new MenuItem()
85+
{
86+
Text ="item 1.3",
87+
Items = new List<MenuItem>()
88+
{
89+
new MenuItem()
90+
{
91+
Text = "item 1.3.1",
92+
},
93+
new MenuItem()
94+
{
95+
Text = "item 1.3.2",
96+
}
97+
}
98+
}
99+
}
100+
},
101+
new MenuItem()
102+
{
103+
Text = "item 2",
104+
Items = new List<MenuItem>()
105+
{
106+
new MenuItem()
107+
{
108+
Text = "item 2.1",
109+
},
110+
new MenuItem()
111+
{
112+
Text = "item 2.2",
113+
}
114+
}
115+
}
116+
};
117+
118+
base.OnInitialized();
119+
}
120+
121+
public class MenuItem
122+
{
123+
public string Text { get; set; }
124+
public string Url { get; set; }
125+
public List<MenuItem> Items { get; set; }
126+
}
127+
}
128+
````
129+
130+
## Next Steps
131+
132+
* [Explore the Menu Templates]({%slug components/menu/templates%})
133+
134+
## See Also
135+
136+
* [Menu Overview]({%slug components/menu/overview%})

components/tooltip/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The Tooltip will automatically display the value of `title` and `alt` attributes
4444

4545
The Tooltip normally appears above its target, but can show on all four sides. If there is not enough space, the component will shift or flip its position automatically. Learn how to [control the Tooltip position]({%slug tooltip-position%}).
4646

47-
## Show Event
47+
## Show Behavior
4848

4949
By default, the Tooltip displays on mouse over, but it is possible to [configure it to show on click or tap]({%slug tooltip-show-event%}).
5050

0 commit comments

Comments
 (0)