fluentui-blazor: fix: NumberFields do not support doubles, decimals, floats
π Bug Report
When inserting a value into a numberfield where the bound value is a double, float or decimal, will not allow the user to enter a value with a decimal. It will instead ask you to enter one the the 2 nearest integers.
π» Repro or Code Sample
<EditForm EditContext="EditContext">
<DataAnnotationsValidator />
<FluentNumberField @bind-Value="ExampleModel.Test" Label="Test" />
<FluentButton Type="ButtonType.Submit">
Submit
</FluentButton>
</EditForm>
@code {
EditContext EditContext { get; set; } = default!;
Model ExampleModel { get; set; } = new Model();
protected override void OnInitialized()
{
base.OnInitialized();
EditContext = new EditContext(ExampleModel);
}
public class Model
{
public double Test { get; set; }
}
}
π€ Expected Behavior
Allows user to submit the form with a value with decimals
π― Current Behavior
When submitting the form, we get this preventing form submission.
π Possible Solution
π¦ Context
I have produced a minimal repro (above) in the base template after having found the issue in my main project in order to isolate it.
π Your Environment
Windows, Chrome, .net 8, 4.2.1 FluentUI
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (2 by maintainers)
@thebarrettlo Iβm in contact with the FAST team again to see what we can do.
@vnbaaij Just to clarify then, we cannot use the NumberField for decimal values whatsoever? I tried setting the step to 0.01 for example and still get the issue (though this would have still been suboptimal, as stepping using the spinner would have been preferable by a different value). All the same though, I am unable in any way, to have the number say β1.2β represented in a NumberField component?
Yes, we are working on that. See https://github.com/microsoft/fluentui-blazor/discussions/3066 and use the search for more
Hi @vnbaaij, I hope you read comments on already closed issues and it is ok to discuss this issue further here.
I also have troubles with the number field and now read your comments, the linked issue and the link provided there. For my application I need a number field with validation (e.g. min/max value) and culture awareness. You now suggest to not use the number field, instead as stated in the provided link a text field with inputmode=numeric should be used. I could now use the FluentTextField and try to set the inputmode with the AddtionalAttributes β maybe the FluentTextField should provide an explicit parameter for that. But in the end, I think I will make no sense to add all those things (min/max value, culture awareness) to the FluentTextField as it is a text field and no number field. Therefore, I see 3 solutions:
<input type="number">but<input type="text" inputmode="number">with support for min/max, culture awareness and custom validation, number formatting (scientific, β¦), integers or floating point, β¦From my perspective,
What do you think about that?