Skip to content

Commit

Permalink
Merge pull request #18783 from abpframework/liangshiwei/customMenu
Browse files Browse the repository at this point in the history
Check if the type is a component before rendering
  • Loading branch information
enisn committed Jan 18, 2024
2 parents 029fd92 + 75598e7 commit 468715c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
@if (MenuItem.IsLeaf)
{
if (customComponentType != null)
if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{
<DynamicComponent Type="@customComponentType" />
}
Expand All @@ -32,7 +32,7 @@ else
{
<li class="nav-item">
<div class="dropdown">
@if (customComponentType != null)
@if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{
<DynamicComponent Type="@customComponentType" />
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
@if (MenuItem.IsLeaf)
{
if (customComponentType != null)
if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{
<DynamicComponent Type="@customComponentType" />
}
Expand All @@ -28,7 +28,7 @@
else
{
<div class="dropdown-submenu">
@if (customComponentType != null)
@if (customComponentType != null && typeof(ComponentBase).IsAssignableFrom(customComponentType))
{
<DynamicComponent Type="@customComponentType" />
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

if (menuItem.IsLeaf)
{
if (customComponentType != null)
if (customComponentType != null && typeof(ViewComponent).IsAssignableFrom(customComponentType))
{
@(await Component.InvokeAsync(customComponentType))
}
Expand All @@ -34,7 +34,7 @@
{
<li class="nav-item">
<div class="dropdown">
@if (customComponentType != null)
@if (customComponentType != null && typeof(ViewComponent).IsAssignableFrom(customComponentType))
{
@(await Component.InvokeAsync(customComponentType))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
@if (Model.IsLeaf)
{
if (customComponentType != null)
if (customComponentType != null && typeof(ViewComponent).IsAssignableFrom(customComponentType))
{
@(await Component.InvokeAsync(customComponentType))
}
Expand All @@ -31,10 +31,10 @@
else
{
<div class="dropdown-submenu">
@if (customComponentType != null)
{
@if (customComponentType != null && typeof(ViewComponent).IsAssignableFrom(customComponentType))
{
@(await Component.InvokeAsync(customComponentType))
}
}
else
{
<a role="button" class="btn dropdown-toggle" data-bs-toggle="dropdown"
Expand Down

0 comments on commit 468715c

Please sign in to comment.