Skip to content

Commit

Permalink
Fix SetTitle | Do not override Id | Make sure to refresh the tabs (#55)
Browse files Browse the repository at this point in the history
* Fix SetTitle | Do not override Id | Make sure to refresh the tabs

* v3.0.1-preview-1

* v3.0.1
  • Loading branch information
David-Moreira authored Dec 30, 2024
1 parent 7f01189 commit fc2b659
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
29 changes: 28 additions & 1 deletion sample/Demo/Pages/Form.razor
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,38 @@
</div>
</div>

<div class="row mt-2">
<div class="col-12">
<div class="form-group">
<label>Define a new title for this tab:</label>
<input class="form-control" placeholder="Define this tab's title" @bind-value=@_newTabTitle>
</div>
</div>
</div>

<div class="row">
<div class="col-12">
<button class="btn btn-primary" @onclick="ChangeTabTitleAsync">Change Tab Title</button>
</div>
</div>




@code {
[CascadingParameter]
public XTabs XTabs { get; set; }
private string _tabTitle = "Formulary";
private string _newTabTitle = "Formulary";

private Task ButtonCloseTabAsync()
=> XTabs.CloseTabByTitleAsync("Formulary");
=> XTabs.CloseTabByTitleAsync(_tabTitle);

private async Task ChangeTabTitleAsync()
{
var tab = XTabs.GetTabByTitle(_tabTitle);
await tab.SetTitle(_newTabTitle);
_tabTitle = _newTabTitle;
}

}
2 changes: 1 addition & 1 deletion src/XTabs/BlazorXTabs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<PropertyGroup>
<PackageId>BlazorXTabs</PackageId>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
<Authors>David Moreira</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<ProjectUrl>https://github.com/David-Moreira/XTabs</ProjectUrl>
Expand Down
8 changes: 3 additions & 5 deletions src/XTabs/XTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,11 @@ public static XTab Create(XTabs parent, string title, RenderFragment renderFragm

#region Protected Methods

public Task SetTitle(string title)
public async Task SetTitle(string title)
{
if (Id == Title)
Id = title;

Title = title;
return TitleChanged.InvokeAsync(title);
await TitleChanged.InvokeAsync(title);
await _parent.NotifyStateHasChangedAsync();
}

public override async Task SetParametersAsync(ParameterView parameters)
Expand Down

0 comments on commit fc2b659

Please sign in to comment.