InputNumber validation breaks when hidden and subsequently rerendered
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
When using an InputNumber backed by a non-nullabe value, deleting the value from the field and changing the rendering breaks the validation message.
```
@page "/example"
@if (pageIndex == 0)
{
Next
}
else if (pageIndex == 1)
{
Back
}
@code
{
private EditContext EditContext { get; set;; }
public int Value { get; set; }
private int pageIndex;
protected override void OnInitialized()
{
EditContext = new EditContext(Value);
}
}
```
### Expected Behavior
The validation message is still linked to the field and can be removed by inputting a valid value.
### Steps To Reproduce
1. Delete the value from the InputNumber field and tab out. See the validation message.
2. Click Next.
3. Click Back.
4. See the validation message still exists even though the field has reset to zero.
5. Delete the value from the InputNumber field and tab out. See a second validation message. The first validation message can not be removed without reloading the page, while the last message can be removed by setting the field to a number.
6. Repeat.
### Exceptions (if any)
_No response_
### .NET Version
7.0.302
### Anything else?
Step 1

Step 4

Step 5

Step 6

Contributor guide
Assessment
This issue has not been assessed yet.