Browse Source
Fix rendering multiple or wrong tabs as selected in Setting Management Blazor
pull/23679/head
enisn
5 months ago
No known key found for this signature in database
GPG Key ID: A052619F04155D1C
2 changed files with
29 additions and
36 deletions
-
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor
-
modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/SettingManagement.razor.cs
|
|
|
@ -12,31 +12,34 @@ |
|
|
|
|
|
|
|
<Card> |
|
|
|
<CardBody Class="pt-3"> |
|
|
|
<Tabs @bind-SelectedTab="@SelectedGroup" TabPosition="TabPosition.Start" Pills="true" RenderMode="TabsRenderMode.LazyReload" VerticalItemsColumnSize="ColumnSize.Is3.OnDesktop.Is6.OnTablet.Is12.OnMobile"> |
|
|
|
<Items> |
|
|
|
@foreach (var group in SettingComponentCreationContext.Groups) |
|
|
|
{ |
|
|
|
<Tab Name="@GetNormalizedString(group.Id)"> |
|
|
|
@group.DisplayName |
|
|
|
</Tab> |
|
|
|
} |
|
|
|
</Items> |
|
|
|
<Content> |
|
|
|
@foreach (var group in SettingComponentCreationContext.Groups) |
|
|
|
{ |
|
|
|
<TabPanel Name="@GetNormalizedString(group.Id)" class="abp-md-form"> |
|
|
|
@{ |
|
|
|
SettingItemRenders.Add(builder => |
|
|
|
{ |
|
|
|
builder.OpenComponent(0, group.ComponentType); |
|
|
|
builder.CloseComponent(); |
|
|
|
}); |
|
|
|
} |
|
|
|
@if (!string.IsNullOrEmpty(SelectedGroup)) |
|
|
|
{ |
|
|
|
<Tabs @bind-SelectedTab="@SelectedGroup" TabPosition="TabPosition.Start" Pills="true" RenderMode="TabsRenderMode.LazyReload" VerticalItemsColumnSize="ColumnSize.Is3.OnDesktop.Is6.OnTablet.Is12.OnMobile"> |
|
|
|
<Items> |
|
|
|
@foreach (var group in SettingComponentCreationContext.Groups) |
|
|
|
{ |
|
|
|
<Tab Name="@GetNormalizedString(group.Id)"> |
|
|
|
@group.DisplayName |
|
|
|
</Tab> |
|
|
|
} |
|
|
|
</Items> |
|
|
|
<Content> |
|
|
|
@foreach (var group in SettingComponentCreationContext.Groups) |
|
|
|
{ |
|
|
|
<TabPanel Name="@GetNormalizedString(group.Id)" class="abp-md-form"> |
|
|
|
@{ |
|
|
|
SettingItemRenders.Add(builder => |
|
|
|
{ |
|
|
|
builder.OpenComponent(0, group.ComponentType); |
|
|
|
builder.CloseComponent(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@SettingItemRenders.Last() |
|
|
|
</TabPanel> |
|
|
|
} |
|
|
|
</Content> |
|
|
|
</Tabs> |
|
|
|
@SettingItemRenders.Last() |
|
|
|
</TabPanel> |
|
|
|
} |
|
|
|
</Content> |
|
|
|
</Tabs> |
|
|
|
} |
|
|
|
</CardBody> |
|
|
|
</Card> |
|
|
|
|
|
|
|
@ -42,21 +42,11 @@ public partial class SettingManagement |
|
|
|
SettingComponentCreationContext.Normalize(); |
|
|
|
SettingItemRenders.Clear(); |
|
|
|
|
|
|
|
if (SettingComponentCreationContext.Groups.Any()) |
|
|
|
if(SelectedGroup.IsNullOrEmpty() && SettingComponentCreationContext.Groups.Any()) |
|
|
|
{ |
|
|
|
SelectedGroup = GetNormalizedString(SettingComponentCreationContext.Groups.First().Id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender) |
|
|
|
{ |
|
|
|
if (firstRender) |
|
|
|
{ |
|
|
|
await Task.Yield(); |
|
|
|
await InvokeAsync(StateHasChanged); |
|
|
|
} |
|
|
|
|
|
|
|
await base.OnAfterRenderAsync(firstRender); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual string GetNormalizedString(string value) |
|
|
|
|