-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
In the InputText component, when using StateHasChanged, the value change is not reflected in the UI of the InputText component.
<div style="margin:130px auto;width:300px">
<div class="form-group">
<label for="inputText">InputText:</label>
<InputText id="inputText" class="form-control" Value="@InputText" ValueExpression="@(() => InputText)" ValueChanged="HandleValueChanged" />
</div>
Current InputText: @InputText
</div>
@code {
public string InputText { get; set; } = "abc";
protected void HandleValueChanged(string? args)
{
if (args != "test")
{
InputText = args;
}
else
{
StateHasChanged();
}
}
}
Expected Behavior
Expected Output: When using StateHasChanged, the value needs to be reflected in the input of the InputText also.
Current Output: When using StateHasChanged, the value is not reflected in the input of the InputText .
Steps To Reproduce
- Run the Sample.
- Type “Example” and focus out.
- Now, The Values are updated properly in Both UI and ValueChanged event args.
- Type “test” and focus out.
Exceptions (if any)
No response
.NET Version
net7.0
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components