Skip to content

fix: FluentTabs.SelectTabAsync fails after manual tab navigation #5443

Closed as duplicate

Description

@sm-khosravi

🐛 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

  1. Open the reproduction page. First tab is initially selected.
  2. Click the Third tab header.
  3. Click the Select first tab button, which calls:
    await _tabs.SelectTabAsync("first");
  4. Observe that the visible tab does not return to First tab, although the bound ActiveTabId becomes "first".

Case 2: Repeated programmatic selection

  1. Reload the page.
  2. Click Select second tab. The second tab opens correctly.
  3. Click the Third tab header manually.
  4. Click Select second tab again.
  5. Observe that the visible tab does not return to Second tab, although the bound ActiveTabId becomes "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]

📎 Attachments

Reproduction project

Test.zip

Screen recording

Video.Project.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions