Repository navigation
Description
🐛 Bug report
In Fluent UI Blazor 5.0.0, FluentTabs.SelectTabAsync does not consistently update the visible tab after manual navigation.
The bound ActiveTabId changes to the requested tab, but the selected tab header and displayed content can remain on the manually selected tab.
A minimal reproduction project and screen recording are attached.
💻 Steps to reproduce
Case 1: Returning to the initially selected tab
- Open the reproduction page. First tab is initially selected.
- Click the Third tab header.
- Click the Select first tab button, which calls:
await _tabs.SelectTabAsync("first");
- Observe that the visible tab does not return to First tab, although the bound
ActiveTabIdbecomes"first".
Case 2: Repeated programmatic selection
- Reload the page.
- Click Select second tab. The second tab opens correctly.
- Click the Third tab header manually.
- Click Select second tab again.
- Observe that the visible tab does not return to Second tab, although the bound
ActiveTabIdbecomes"second".
🤔 Expected behavior
Every call to SelectTabAsync with a valid, enabled, visible tab ID should synchronize:
- The bound
ActiveTabId. - The selected tab header.
- The displayed tab content.
This should work regardless of previous manual or programmatic navigation.
😯 Actual behavior
Returning programmatically to the initial tab, or to a previously selected programmatic target, can update the bound ID without updating the visible selection.
💻 Minimal code
@page "/tab-selection-bug"
@rendermode InteractiveServer
@using Microsoft.FluentUI.AspNetCore.Components
@using static Microsoft.AspNetCore.Components.Web.RenderMode
<FluentTabs @ref="_tabs" @bind-ActiveTabId="_activeTabId">
<FluentTab Id="first" Header="First tab" DeferredLoading="false">
<p>First tab content</p>
</FluentTab>
<FluentTab Id="second" Header="Second tab" DeferredLoading="false">
<p>Second tab content</p>
</FluentTab>
<FluentTab Id="third" Header="Third tab" DeferredLoading="false">
<p>Third tab content</p>
</FluentTab>
</FluentTabs>
<button type="button" @onclick='() => SelectAsync("first")'>
Select first tab
</button>
<button type="button" @onclick='() => SelectAsync("second")'>
Select second tab
</button>
<p>Bound ActiveTabId: @_activeTabId</p>
@code {
private FluentTabs? _tabs;
private string? _activeTabId = "first";
private async Task SelectAsync(string tabId)
{
if (_tabs is not null)
{
await _tabs.SelectTabAsync(tabId);
}
}
}💁 Possible cause
From inspecting the 5.0.0 implementation, manual navigation updates the client-side selection while ActiveTabIdAttribute retains the previously rendered value.
When SelectTabAsync requests that same value again, Blazor's render diff may see no attribute change and therefore not reapply activeid to the underlying fluent-tablist.
Explicitly synchronizing the web component's activeid attribute works around the problem.
🔦 Impact
This prevents reliable navigation to the first invalid tab in a multi-tab form when the user submits repeatedly after manually switching tabs.
The attached reproduction does not require forms or validation.
🌍 Environment
- Microsoft.FluentUI.AspNetCore.Components: 5.0.0
- .NET: 10
- Render mode: Interactive Server
- OS: Windows
- Browser and version: [enter the browser used for the recording]
Activity