Revert "Fix for Tabpanel is not updating the UI. #4778"
This commit is contained in:
parent
1ed4c8a094
commit
a5ccc23604
|
@ -10,7 +10,7 @@
|
|||
@if (_initialized)
|
||||
{
|
||||
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||
<TabStrip Refresh="@_refresh" ActiveTab="@_activetab">
|
||||
<TabStrip Refresh="@_refresh">
|
||||
<TabPanel Name="Settings" ResourceKey="Settings" Heading="Settings">
|
||||
<div class="container">
|
||||
<div class="row mb-1 align-items-center">
|
||||
|
@ -246,7 +246,6 @@
|
|||
private string _iconresources = "";
|
||||
private DateTime? _effectivedate = null;
|
||||
private DateTime? _expirydate = null;
|
||||
private string _activetab = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
@ -336,7 +335,6 @@
|
|||
|
||||
private async Task SavePage()
|
||||
{
|
||||
_activetab = "Settings";
|
||||
validated = true;
|
||||
var interop = new Interop(JSRuntime);
|
||||
if (await interop.FormValid(form))
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate>
|
||||
@if (_page.UserId == null)
|
||||
{
|
||||
<TabStrip Refresh="@_refresh" ActiveTab="@_activetab">
|
||||
<TabStrip Refresh="@_refresh">
|
||||
<TabPanel Name="Settings" ResourceKey="Settings" Heading="Settings">
|
||||
<div class="container">
|
||||
<div class="row mb-1 align-items-center">
|
||||
|
@ -356,7 +356,6 @@
|
|||
private string _iconresources = "";
|
||||
private DateTime? _effectivedate = null;
|
||||
private DateTime? _expirydate = null;
|
||||
private string _activetab = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
@ -523,7 +522,6 @@
|
|||
|
||||
private async Task SavePage()
|
||||
{
|
||||
_activetab = "Settings";
|
||||
validated = true;
|
||||
var interop = new Interop(JSRuntime);
|
||||
if (await interop.FormValid(form))
|
||||
|
|
|
@ -30,8 +30,6 @@ else
|
|||
[Parameter]
|
||||
public SecurityAccessLevel? Security { get; set; } // optional - can be used to specify SecurityAccessLevel
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
base.OnParametersSet();
|
||||
|
|
|
@ -8,9 +8,18 @@
|
|||
@foreach (TabPanel tabPanel in _tabPanels)
|
||||
{
|
||||
<li class="nav-item" @key="tabPanel.Name">
|
||||
<a class="nav-link @(tabPanel.IsActive ? "active" : "")" data-bs-toggle="tab" href="#@(Id + tabPanel.Name)" role="tab" @onclick:preventDefault="true" @onclick="() => SetActiveTab(tabPanel.Name)">
|
||||
@if (tabPanel.Name.ToLower() == ActiveTab.ToLower())
|
||||
{
|
||||
<a class="nav-link active" data-bs-toggle="tab" href="#@(Id + tabPanel.Name)" role="tab" @onclick:preventDefault="true">
|
||||
@tabPanel.DisplayHeading()
|
||||
</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="nav-link" data-bs-toggle="tab" href="#@(Id + tabPanel.Name)" role="tab" @onclick:preventDefault="true">
|
||||
@tabPanel.DisplayHeading()
|
||||
</a>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
|
@ -52,41 +61,14 @@
|
|||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
base.OnParametersSet();
|
||||
|
||||
if (PageState.QueryString.ContainsKey("tab"))
|
||||
{
|
||||
ActiveTab = PageState.QueryString["tab"];
|
||||
}
|
||||
|
||||
if (_tabPanels == null || Refresh)
|
||||
{
|
||||
_tabPanels = new List<TabPanel>();
|
||||
}
|
||||
|
||||
// Ensure the active tab is valid and exists
|
||||
if (!string.IsNullOrEmpty(ActiveTab) && _tabPanels.Any())
|
||||
{
|
||||
var activeTabExists = _tabPanels.Any(tp => tp.Name.Equals(ActiveTab, StringComparison.OrdinalIgnoreCase));
|
||||
if (!activeTabExists)
|
||||
{
|
||||
ActiveTab = _tabPanels[0].Name;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the active tab in the UI
|
||||
UpdateActiveTab();
|
||||
}
|
||||
|
||||
private void UpdateActiveTab()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ActiveTab) && _tabPanels != null)
|
||||
{
|
||||
foreach (var tabPanel in _tabPanels)
|
||||
{
|
||||
tabPanel.IsActive = tabPanel.Name.Equals(ActiveTab, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void AddTabPanel(TabPanel tabPanel)
|
||||
|
@ -94,20 +76,12 @@
|
|||
if (!_tabPanels.Exists(item => item.Name == tabPanel.Name) && IsAuthorized(tabPanel))
|
||||
{
|
||||
_tabPanels.Add(tabPanel);
|
||||
StateHasChanged();
|
||||
}
|
||||
if (string.IsNullOrEmpty(ActiveTab))
|
||||
{
|
||||
ActiveTab = tabPanel.Name;
|
||||
}
|
||||
UpdateActiveTab();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetActiveTab(string tabName)
|
||||
{
|
||||
ActiveTab = tabName;
|
||||
UpdateActiveTab();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private bool IsAuthorized(TabPanel tabPanel)
|
||||
|
|
Loading…
Reference in New Issue
Block a user