Skip to content

fix: Number Field within an editform using validation will permanently break if a number outside the bounds of the type is entered #1345

Open
@pingu2k4

Description

@pingu2k4

🐛 Bug Report

Create an edit form with data validation, and insert a FluentNumberField.
When you enter a number large than the maximum allowed (or presumably lower than the minimum allowed), you get a validation error "The {property} field must be a number.". When you then enter a more sensible value, the validation error remains and the form remains unsubmittable and the form will not work until it is recreated.

💻 Repro or Code Sample

<EditForm EditContext="EditContext">
    <DataAnnotationsValidator />

    <FluentNumberField @bind-Value="MyModel.MyInt" Label="My Int" Immediate="true" />
    <FluentValidationMessage For="() => MyModel.MyInt" />
</EditForm>

@code {
    Model MyModel { get; set; } = new();
    EditContext EditContext { get; set; } = default!;

    protected override void OnInitialized()
    {
        base.OnInitialized();

        EditContext = new(MyModel);
    }

    public class Model
    {
        public int MyInt { get; set; }
    }
}
  • Enter "1" in the box
  • Repeatedly enter "0" after the current value in the box until the error appears
  • Remove 0's and notice that the box never validated correctly and the form is now unusable

🤔 Expected Behavior

Error message should represent the actual issue, not state that it is not a number.
Then, when number is corrected, the field and form should operate correctly once again.

😯 Current Behavior

image

💁 Possible Solution

🔦 Context

This makes using NumberFields and form validation difficult to justify.

🌍 Your Environment

  • OS & Device: Windows
  • Browser Chrome (Latest)
  • .NET 8, FluentUI 4.3.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions