Element: [Bug Report] Decimal separator format in el-input-number

Created on 1 Mar 2018  ·  15Comments  ·  Source: ElemeFE/element

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 ",".

input-number discussion feature request

Most helpful comment

Waiting for this

All 15 comments

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 vs 10.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 :(

现在的 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 😿

Was this page helpful?
0 / 5 - 0 ratings