element
element copied to clipboard
[Bug Report] Decimal separator format in el-input-number
Element UI version
2.2.0
OS/Browsers version
Chrome Version 64.0.3282.186
Vue version
2.5.13
Reproduction Link
https://jsfiddle.net/mmx38qxw/393/
Steps to reproduce
Introduce "2,23" with a comma instead of a dot.
What is Expected?
Format the number with decimals correctly either using separator "," or "." for internationalization purposes. Or add a new prop for stablishing the decimal separator character.
What is actually happening?
The new number is not valid and dissapears if the decimal separator is not ",".
Also see: https://github.com/ElemeFE/element/issues/8515
Need elaboration on behavior:
- should the component consider both separator to be valid?
- how to determine which one is decimal point in mixed input, eg:
10,000.30
vs10.000,30
- what if user inputs
1,3
where locale says decimal point is.
- consider vue-i18n / native Intl ?
How to test i18n related stuff in tests? (Also daylight saving time, see date-picker's test)
Thanks for your reply.
- In my opinion, the thousands separator on a form float input is useless, it's only valid for readability purposes (due to database persistency behaviour).
- The decimal separator could be passed as a prop and used after in the regexp for formatting.
- If the decimal separator is switched, then a simple string replace should occur to the valid one, thus giving the user a visual hint of what is happening by the way, not needing any more visual aid.
- My idea is to use the i18n key in order to pass the needed character, as I'm actually doing for the ElDatePicker component "format" prop.
I believe those changes will not take too long and will improve que i18n of the component.
@Leopoldthecoder
I'm inclined to adding a prop decimal-separator
which defaults to '.'
. i18n may not be a good place to put such a key, as in most cases the decimal separator is the same among different languages.
That would be awesome.
Any news on this one? I'm looking forward this feature.
There any news on this ? Thanks!
No advances in 5 months? This makes me sad :(
能直接借鉴过来吗?https://www.iviewui.com/components/input-number
现在的 el-input-number 感觉可有可无,完全没有起到这个组件的作用楼上那个真的可以借鉴下
Any news on this feature, please? Cheers!
wish supporting for displaying custom units after Numbers!
Waiting for this
It can't be this hard to allow comma separated numbers right? It is the common decimal separator in alot of languages.
also waiting for this 😿
It would be a nice feature if we can set the decimal-separator
prop.
I have modified the component to allow add thousands separator and decimal separators.
It's in https://gist.github.com/Saigesp/e662683ac6c79471de63d91bc2721a2f, in case it's useful for anyone
Could you use numbro.js to format the numbers? It is a good choice
@Leopoldthecoder Any update here? Is the decimal-separator
prop coming any soon?
Cheers!
Hi guys ) Any updates here? Or maybe it is possible to do it with formatter and parser with el-input?