-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MudNumericField: Change default InputMode to decimal #9923
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: Change default InputMode to decimal #9923
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #9923 +/- ##
==========================================
+ Coverage 89.82% 90.82% +0.99%
==========================================
Files 412 412
Lines 11878 12867 +989
Branches 2364 2487 +123
==========================================
+ Hits 10670 11687 +1017
+ Misses 681 618 -63
- Partials 527 562 +35 ☔ View full report in Codecov by Sentry. |
I wanted to point out that I did see this mentioned in the contributing guidelines: https://github.com/MudBlazor/MudBlazor/blob/dev/CONTRIBUTING.md#avoid-overwriting-parameters-in-blazor-components Correct me if I'm wrong, but I don't think this is applicable here because it's being changed in the constructor, so it won't have an issue of re-running when re-rendering. There is also no event for InputModeChanged. If this does need tackled in a different way though, just let me know. |
You probably need to update the xmldoc MudBlazor/src/MudBlazor/Components/NumericField/MudNumericField.razor.cs Lines 404 to 405 in 0abf26d
|
Yes, it's not applicable when we talk about constructor. Tho if we spoke about v8 I'd probably would want to have something like this: [Parameter]
-public override InputMode InputMode { get; set; } = InputMode.numeric;
+public override InputMode? InputMode { get; set; } = null;
+private InputMode GetInputMode()
+{
+ if (InputMode.HasValue)
+ {
+ return InputMode.Value;
+ }
+
+ var numericTypes = new[]
+ {
+ typeof(sbyte), typeof(sbyte?), typeof(byte), typeof(byte?),
+ typeof(short), typeof(short?), typeof(ushort), typeof(ushort?),
+ typeof(int), typeof(int?), typeof(uint), typeof(uint?),
+ typeof(long), typeof(long?), typeof(ulong), typeof(ulong?)
+ };
+
+ var decimalTypes = new[]
+ {
+ typeof(float), typeof(float?), typeof(double), typeof(double?),
+ typeof(decimal), typeof(decimal?)
+ };
+
+ if (numericTypes.Contains(typeof(T)))
+ {
+ return MudBlazor.InputMode.numeric;
+ }
+
+ if (decimalTypes.Contains(typeof(T)))
+ {
+ return MudBlazor.InputMode.@decimal;
+ }
+
+ return MudBlazor.InputMode.numeric;
+} It's weird to me that the Anyway, I will let @henon to decide this one. If we merge it in v7 or we keep it v8 which will be started soon. |
We'll merge this in v8, just to be sure. It can be in preview.1 which we can make available end of next week or so. Then you can already use it. Is that a good compromise @Eddie-Hartman ? |
@henon please don't compromise for that. I truly wasn't trying to make a mountain out of molehill or make you all go out of your way. I was just generally trying to better understand the thought process of how these types of things get fixed and playing devil's advocate since I rely so heavily on this library and felt like it is an actual bug scenario. I'd have to review any other breaking changes in V8 as well and likely won't be rushing to upgrade right away with what may be other breaking changes (yes I'm aware of the irony). Let me know if you need me to update anything to follow more closely what ScarletKuro suggested. Stick to your timelines. It's a great library and I want it to stay great so keep doing what you're doing bc it's working. 🙂 |
I plan to create a roadmap thread outlining what will be done in v8. v8 will be a logical continuation of v7, primarily dropping .NET 7, removing obsolete APIs, and changing behaviors that make more sense (like in this PR). There will be few renames but mainly the typo ones and things that interfere (like this one #9434 (comment)). We do not plan to make fundamental changes, like replacing SVG icons with Font icons at this stage. I think this will be postponed to v9. I hope the transition will be smoother and easier. Considering that the v7 will be deprecated and will not receive any support, even from the community. |
@henon so are we merging this into v8? |
Thanks! |
It looks like this change introduces an unexpected behaviour when the application language/culture uses comma as a decimal separator. When opening the application in a browser with a language that uses period as a decimal separator, the comma is not accepted by the Example 1:
Example 2:
Example 3:
So setting the |
@andrejpanjan Thanks for the comment. Knowing that, would your comment be better as a new issue? Also, your example 1 sounds like it might be a browser limitation (or trying to adhere to a standard in some way) rather than a component specific bug. In other words, Chrome is running in English, and therefore not expecting a comma as a decimal separator regardless of the fact that the app is "running" in Slovenian. I'm not super familiar with localization and cultures for the web and how it interacts with Blazor, but maybe make sure you're setting the culture properly for the page/browser itself and not just the Blazor app itself. Regardless, I think you'd get results faster with a new issue. |
MudNumericField: Change default InputMode for numeric types that require decimals. (#4198)
Description
Fixes #4198
How Has This Been Tested?
Ran MudBlazor.Docs.Server with a devtunnel to connect an iPhone using Safari browser and checked MudNumericField, MudDataGrid, and MudColorPicker for appropriate updates. Did the same with a Windows machine using Chrome and an Android device using Chrome to make sure there were no other breaking changes.
Also modified the NumericFieldBasicExample.razor to ensure that a user can override the default back to InputMode numeric if they so desired. (Not included in PR, just for testing purposes.)
Type of Changes
Checklist
dev
).