Skip to content

Commit 1b65955

Browse files
committed
chore(kb-drawer): add navigation to the Prevent Collapse Drawer KB
1 parent cb315f1 commit 1b65955

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

knowledge-base/drawer-prevent-collapse.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ I would like to prevent the Drawer from collapsing when an item from the navigat
3333
>caption Stop the Drawer from collapsing on item click
3434
3535
````CSHTML
36-
@* Toggle the expanded or collapsed state only by a button click *@
36+
@* Toggle the expanded or collapsed state only by a button click. Clicking on a Drawer item will navigate you to the value of the Text property of the DrawerItem class. See the SelectAndNavigate method for reference *@
37+
38+
@inject NavigationManager navManager
3739
3840
<TelerikDrawer @bind-Expanded="@DrawerExpanded"
3941
Data="@Data"
@@ -48,14 +50,14 @@ I would like to prevent the Drawer from collapsing when an item from the navigat
4850
{
4951
@* stop the propagation of the onclick event to prevent the drawer from collapsing *@
5052
@* Use onclick to handle manual item selection and toggle the selected class *@
51-
<li @onclick:stopPropagation
52-
@onclick="@(() => SelectedItem = item)"
53+
<li @onclick:stopPropagation
54+
@onclick="@(() => SelectAndNavigate(item))"
5355
class="k-drawer-item @GetSelectedItemClass(item)"
5456
style="white-space:nowrap">
5557
<span class="k-icon k-i-@item.Icon" style="margin-right: 8px;"></span>
5658
@if (DrawerExpanded)
5759
{
58-
<span class="k-item-text">@item.Text</span>
60+
<span class="k-item-text">@item.Text</span>
5961
}
6062
</li>
6163
}
@@ -80,6 +82,13 @@ I would like to prevent the Drawer from collapsing when an item from the navigat
8082
new DrawerItem {Text = "Calendar", Icon = IconName.Calendar, Description = "My events"},
8183
};
8284
85+
private void SelectAndNavigate(DrawerItem item)
86+
{
87+
SelectedItem = item;
88+
89+
navManager.NavigateTo(SelectedItem.Text);
90+
}
91+
8392
public string GetSelectedItemClass(DrawerItem item)
8493
{
8594
if (SelectedItem == null) return string.Empty;

0 commit comments

Comments
 (0)