diff --git a/src/Masa.Blazor/Components/List/MListItem.razor b/src/Masa.Blazor/Components/List/MListItem.razor index 3761389bfa..478bc75b69 100644 --- a/src/Masa.Blazor/Components/List/MListItem.razor +++ b/src/Masa.Blazor/Components/List/MListItem.razor @@ -4,14 +4,14 @@ + Style="@GetStyle()" + Tag="@Tag" + ReferenceCaptureAction="r => Ref = r" + id="@Id" + @onclick="HandleOnClick" + __internal_stopPropagation_onclick="@OnClickStopPropagation" + __internal_preventDefault_onclick="@OnClickPreventDefault" + @attributes="@Attributes"> @if (ItemContent != null) { @ItemContent?.Invoke(GenItemContext()) @@ -52,15 +52,25 @@ RenderFragment GenContent() => __builder => { - if (HasBuiltInContent) + var hasTitle = !string.IsNullOrWhiteSpace(Title); + var hasSubtitle = !string.IsNullOrWhiteSpace(Subtitle); + + if (hasTitle || hasSubtitle) { - - @Title - - - @Subtitle - + @if (hasTitle) + { + + @Title + + } + + @if (hasSubtitle) + { + + @Subtitle + + } } }; diff --git a/src/Masa.Blazor/Components/List/MListItem.razor.cs b/src/Masa.Blazor/Components/List/MListItem.razor.cs index 0a35988914..d84534fe6b 100644 --- a/src/Masa.Blazor/Components/List/MListItem.razor.cs +++ b/src/Masa.Blazor/Components/List/MListItem.razor.cs @@ -125,8 +125,6 @@ public bool IsDark protected override bool IsRoutable => Href != null && List?.Routable is true; - private bool HasBuiltInContent => !string.IsNullOrWhiteSpace(Title) || !string.IsNullOrWhiteSpace(Subtitle); - protected override bool AfterHandleEventShouldRender() => false; protected virtual async Task HandleOnClick(MouseEventArgs args)