Consider this MudTextField that contains a value of type decimal.
<MudTextField Value="@Quantity" ValueChanged="(q=> OnValueChanged(q, context))" T="decimal" />
Suppose this field contains value 1 and the user wants to input a negative value of lets say -1.
So backspace is pressed and the value becomes '-'. At that point MudTextField errors out with 'not a valid number' and the value changes to '0'. So then another backspace is needed to remove the zero and then add minus sign again.
It's just not user friendly, a bit weird what happens.
Is there a way to have a MudTextField with decimal that is able to have a value of '-'?
Looks like you are also using Immediate="true"
(the equivalent of @bind:event="oninput"
)
If you use @bind:event="oninput" then you're asking the binding system to bind on every keystroke. This inherently supposes that every state along the way will be valid and representable in the type you're binding to.
The minus '-' character is not a valid decimal number so that's why it becomes 0.
Check this issue: https://github.com/dotnet/aspnetcore/issues/30033#issuecomment-779170243