Skip to content

[dev-v5] fix: conditional AutoFocus #4699

@MarvinKlein1508

Description

@MarvinKlein1508

🐛 Bug Report

The AutoFocus parameter does not work when a component is being rendered conditionally.

💻 Repro or Code Sample

<FluentSwitch @bind-Value="showInput" Label="Show Input" />

<br />

@if (showInput)
{
    <FluentTextInput @bind-Value="test" Label="Test" Autofocus />
}

@code {
    private string test = string.Empty;
    private bool showInput;
}
  1. Run code
  2. Press the switch
  3. Notice that the input won't get focused

🤔 Expected Behavior

The input should become focused once it is visible

😯 Current Behavior

The input will become visible but won't be set in focus.

💁 Possible Solution

🔦 Context

If you just render the component without the if then it actually will get focused.

🌍 Your Environment

  • OS & Device: Windows 11 64 Bit
  • Browser latest Firefox, Chrome, Edge
  • latest dev-v5 branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bugv5For the next major version

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions