Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MudNumericField autocorrects invalid input using wrong decimal separator instead of just validating #8937

Open
1 of 2 tasks
jiri-panek opened this issue May 10, 2024 · 0 comments

Comments

@jiri-panek
Copy link

jiri-panek commented May 10, 2024

Bug type

Component

Component name

MudNumericField

What happened?

MudNumericField autocorrects invalid input instead of just validating. It is way worse situation to autocorrect number with digits after unsupported decimal separator without user noticing, than just leave the value untouched with validation message.

Prime example is using MudNumericField for currency input. Application could switch between different CultureInfo settings or the user could use their local decimal separator. When the decimal separator is different, then the culture currently set, MudNumeric field autocorrects input value for example from 123,5 to 1235 which could be a big problem.

This autocorrect behavior should not be set by default, or at least there should be option to disable it.

Update:

Maybe it is not incorrect behaviour, since I am using en-US culture and ',' character is used as CultureInfo.NumberFormat.CurrencyGroupSeparator and CultureInfo.NumberFormat.NumberGroupSeparator.

With my culture settings, we use ',' as a decimal separator. So it's easy to make a mistake. So while the autocorrect function may not be wrong, I would still like to have a way to disable this autocorrect behavior. Instead I would rather call validation method.

Expected behavior

MudNumericField does not autocorrect invalid value.

Reproduction link

https://try.mudblazor.com/snippet/wOweOTbkmigbVTCr

Reproduction steps

  1. Input decimal value with at least one non-zero digit after decimal separator into MudNumericField using different separator than CultureInfo.CurrentCulture is using, for example if en-US culture is set, use ',' as decimal separator. Input for example "0,5" if CurrentCulture is using different separator than ','.
  2. Switch focus using tab or just click some other page element (button).
  3. See how MudNumericField autocorrected value with simply removing decimal separator.

Relevant log output

No response

Version (bug)

6.19.1

Version (working)

No response

What browsers are you seeing the problem on?

Edge

On which operating systems are you experiencing the issue?

Windows

Pull Request

  • I would like to do a Pull Request

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant