dotnet / dotnet/aspnetcore

When using StateHasChanged, the value is not reflected in the InputText

Open
#49,069 7 comments 0 reactions 0 assignees View on GitHub
area-blazor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] 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.

```



InputText:


Current InputText: @InputText

@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

1. Run the Sample.
2. Type “Example” and focus out.
3. Now, The Values are updated properly in Both UI and ValueChanged event args.
4. Type “test” and focus out.

### Exceptions (if any)

_No response_

### .NET Version

net7.0

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.