-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
InputNumber formatting for decimal numbers #60112
base: main
Are you sure you want to change the base?
Conversation
Thanks for your PR, @vertonghenb. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
/// <summary> | ||
/// Gets or sets the format to be used when displaying a number of types: <see cref="float"/>, <see cref="double"/>, <see cref="decimal"/>. | ||
/// </summary> | ||
[Parameter] public string? Format { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this works E2E given that https://github.com/dotnet/aspnetcore/pull/60112/files#diff-e63dfe1bc840c170976630c438fc566bcf463606ba3b6c14970d4eac0f898751R61 this is a type=number
input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good starting point, but it needs E2E tests. I'm not confident the format bit will work with InputNumber since it creates an underlying <input type="number" />
element, which I believe doesn't take any format as it's a number
value in JS
InputNumber with formatting (double, decimal, float)
Summary of the changes
InputNumber
with formatting as in0.00
or#.00
etc.Description
In
<InputDate
we can choose how to format the date using the types. e.g.mm/yyyy
etc. WithInputNumber
this is not possible to format decimal numbers. This PR intends to format theInputNumber
with floating point numbers.Scope
The following are in scope:
double
float
decimal
API
In this case the decimal will always have
2 trailing zero's
.In this case the decimal will always have
4 trailing zero's
.Other possible formats:
"1.1"
"0.0#"
"1.1"
"1500"
"0.00"
"1500.00"
"1500"
"0.0000"
"1500.0000"
"1500"
"0.##"
"1500"
"0"
"0.00"
"0.00"
"0"
"0.##"
"0"
"-1.1"
"0.0#"
"-1.1"
"-1500"
"0.00"
"-1500.00"
"1.999"
"0.0"
"2.0"
"1.111"
"0.0"
"1.1"
"1234567.89"
"N2"
"1,234,567.89"
"1234567.89"
"#,##0.00"
"1,234,567.89"
"0.1234"
"0.00%"
"12.34%"
"0.12"
"00.00"
"00.12"
"1234567.89"
"0.00"
"1234567.89"
Notes:
type="number"
on the input might stop us from showing thousand separators. since1.000,01
won't show in thetype="number".
I don't think we want to change the type totext
since we might break existing usage.Any idea's how to solve this problem are welcome. The other formats will work as expected.
Idea's
Haven't tested it but using
inputmode
andpattern
might accomplish the same:<input type="text" pattern="^[0-9․,]+$" inputmode="decimal"/>
Fixes #30567