Skip to content

MudNumericField: Ignore default UI Culture#10734

Merged
henon merged 7 commits intoMudBlazor:devfrom
Anu6is:10730-MudNumericField-IgnoreDefaultCulture
Jan 31, 2025
Merged

MudNumericField: Ignore default UI Culture#10734
henon merged 7 commits intoMudBlazor:devfrom
Anu6is:10730-MudNumericField-IgnoreDefaultCulture

Conversation

@Anu6is
Copy link
Copy Markdown
Contributor

@Anu6is Anu6is commented Jan 27, 2025

Description

The base MudNumericField renders a simple <input type="number" ...> element as of #10192. The goal of <input type="number"> is to provide a predictable, universal format for numerical data input. As such, it behaves in the following manner

  • Decimal Separator: Always uses a dot (.) as the decimal separator, regardless of the user's culture.
  • Thousands Separator: Does not support thousands separators (e.g., no commas or spaces for grouping digits).
  • Input Format: The expected format is [-]digits[.digits], which is language-neutral and not localized.

If a user wants anything more advanced, they would define for themselves the Culture, Pattern or Format to be used. When any of these are defined, the MudNumericField will instead render an <input type="text" ...> element. Currently, when Culture isn't defined, it defaults to the UI Culture. When the DefaultConverter attempts to convert the user input, it uses the UI Culture for the conversion. As culture is not supported by <input type="number" ...> it should be ignored during conversion.

Resolves #10730

How Has This Been Tested?

Visually and unit tests

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@github-actions github-actions bot added bug Unexpected behavior or functionality not working as intended PR: needs review labels Jan 27, 2025
@Anu6is Anu6is requested a review from ScarletKuro January 27, 2025 16:52
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.83%. Comparing base (7a94bc3) to head (3ec2264).
Report is 5 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #10734      +/-   ##
==========================================
- Coverage   91.84%   91.83%   -0.01%     
==========================================
  Files         427      427              
  Lines       13428    13430       +2     
  Branches     2591     2592       +1     
==========================================
+ Hits        12333    12334       +1     
  Misses        523      523              
- Partials      572      573       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@henon
Copy link
Copy Markdown
Contributor

henon commented Jan 30, 2025

I agree. Should we put an alert on the docs that numeric field does not automatically adjust to the UICulture due to technical limitations and that the user should make sure to set Culture accordingly?

@Anu6is
Copy link
Copy Markdown
Contributor Author

Anu6is commented Jan 30, 2025

Should we put an alert on the docs that numeric field does not automatically adjust to the UICulture due to technical limitations and that the user should make sure to set Culture accordingly

Yeah I could do that

Copy link
Copy Markdown
Member

@ScarletKuro ScarletKuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ScarletKuro ScarletKuro requested a review from henon January 30, 2025 20:23
@Anu6is
Copy link
Copy Markdown
Contributor Author

Anu6is commented Jan 30, 2025

@henon see added doc alert

@sonarqubecloud
Copy link
Copy Markdown

@henon henon merged commit cdf490e into MudBlazor:dev Jan 31, 2025
@henon
Copy link
Copy Markdown
Contributor

henon commented Jan 31, 2025

The alert in the docs is very good. Thanks a lot @Anu6is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MudNumericField input of type double does not work

3 participants