Skip to content

Commit

Permalink
Fixes prerendering issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jbomhold3 committed Sep 26, 2019
1 parent bd9cae5 commit 7181fa6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/BlazorStrap/Components/Tabs/BSTabGroup.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace BlazorStrap
public abstract class BSTabGroupBase : ComponentBase
{
internal bool Disposing { get; set; } = false;
internal bool HasRendered { get; set; } = false;
[Parameter(CaptureUnmatchedValues = true)] public IDictionary<string, object> UnknownParameters { get; set; }
public List<BSTabBase> Tabs { get; set; } = new List<BSTabBase>();
internal List<EventCallback<BSTabEvent>> EventQue { get; set; } = new List<EventCallback<BSTabEvent>>();
Expand All @@ -20,10 +21,13 @@ public BSTabBase Selected
if (Disposing) return;
BSTabEvent = new BSTabEvent() { Activated = value, Deactivated = _selected };

ShowEvent.InvokeAsync(BSTabEvent);
HideEvent.InvokeAsync(BSTabEvent);
EventQue.Add(ShownEvent);
EventQue.Add(HiddenEvent);
if (HasRendered)
{
InvokeAsync(() => ShowEvent.InvokeAsync(BSTabEvent));
InvokeAsync(() => HideEvent.InvokeAsync(BSTabEvent));
EventQue.Add(ShownEvent);
EventQue.Add(HiddenEvent);
}
_selected = value;
InvokeAsync(StateHasChanged);
}
Expand All @@ -37,6 +41,10 @@ public BSTabBase Selected

protected override Task OnAfterRenderAsync(bool firstrun)
{
if (firstrun)
{
HasRendered = true;
}
for (var i = 0; i < EventQue.Count; i++)
{
EventQue[i].InvokeAsync(BSTabEvent);
Expand Down

0 comments on commit 7181fa6

Please sign in to comment.