Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Blazor Wasm does not honor binding if previous value is a part of the new value for textarea when using oninput
Expected Behavior
I expect the textarea to render the new value.
Steps To Reproduce
- Start new Blazor Wasm project (.Net 6 or .Net 7)
- Copy the following code into Index.razor
- type "12345" into the first textarea
3a) the textarea renders "12345" instead of "1234" even though the underlying value is "1234" - type "12345" into the second textarea
4a) the textarea renders the correct value of "abcd", but if you keep typing the same result of the textarea occurs
<div class="row">
<div class="col">
<br />
</div>
</div>
<div class="col">
<textarea value="@InputValue1"
@oninput="@OnTextAreaInput1">
</textarea>
</div>
<div class="row">
<div class="col">
<label>InputValue1 = @InputValue1</label>
</div>
</div>
<div class="row">
<div class="col">
<br />
<hr />
<br />
</div>
</div>
<div class="col">
<textarea value="@InputValue2"
@oninput="@OnTextAreaInput2">
</textarea>
</div>
<div class="row">
<div class="col">
<label>InputValue2 = @InputValue2</label>
</div>
</div>
@code {
protected string? InputValue1 { get; set; }
protected void OnTextAreaInput1(ChangeEventArgs changeEventArgs)
{
var newValue = changeEventArgs.Value?.ToString() ?? string.Empty;
InputValue1 = newValue.Length > 4
? "1234"
: InputValue1 = newValue;
}
// *************************************************************
protected string? InputValue2 { get; set; }
protected void OnTextAreaInput2(ChangeEventArgs changeEventArgs)
{
var newValue = changeEventArgs.Value?.ToString() ?? string.Empty;
InputValue2 = newValue.Length > 4
? "abcd"
: InputValue2 = newValue;
}
}
Exceptions (if any)
No unhandled exception
.NET Version
.Net 6 & .Net 7