element icon indicating copy to clipboard operation
element copied to clipboard

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

Open fergardi opened this issue 6 years ago • 20 comments

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

fergardi avatar Mar 01 '18 13:03 fergardi

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)

wacky6 avatar Mar 01 '18 15:03 wacky6

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.

fergardi avatar Mar 06 '18 12:03 fergardi

@Leopoldthecoder

wacky6 avatar Mar 06 '18 13:03 wacky6

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.

Leopoldthecoder avatar Mar 11 '18 12:03 Leopoldthecoder

That would be awesome.

fergardi avatar Mar 15 '18 11:03 fergardi

Any news on this one? I'm looking forward this feature.

fergardi avatar Apr 10 '18 13:04 fergardi

There any news on this ? Thanks!

jaime-marcondes avatar Jun 11 '18 21:06 jaime-marcondes

No advances in 5 months? This makes me sad :(

fergardi avatar Aug 02 '18 07:08 fergardi

能直接借鉴过来吗?https://www.iviewui.com/components/input-number

cuivip avatar Aug 14 '18 12:08 cuivip

现在的 el-input-number 感觉可有可无,完全没有起到这个组件的作用楼上那个真的可以借鉴下

jiankafei avatar Mar 25 '19 03:03 jiankafei

Any news on this feature, please? Cheers!

duyhung85 avatar Apr 12 '19 02:04 duyhung85

wish supporting for displaying custom units after Numbers!

wbpmrck avatar Apr 19 '19 09:04 wbpmrck

Waiting for this

edum18 avatar Aug 22 '19 10:08 edum18

It can't be this hard to allow comma separated numbers right? It is the common decimal separator in alot of languages.

nielsvhb avatar Apr 13 '20 12:04 nielsvhb

also waiting for this 😿

kotapeter avatar Apr 30 '20 14:04 kotapeter

It would be a nice feature if we can set the decimal-separator prop.

lszucsPmi avatar Feb 03 '21 08:02 lszucsPmi

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

Saigesp avatar Jul 28 '21 14:07 Saigesp

Could you use numbro.js to format the numbers? It is a good choice

robertovaldesperez avatar Dec 17 '21 22:12 robertovaldesperez

@Leopoldthecoder Any update here? Is the decimal-separator prop coming any soon? Cheers!

Komald avatar Nov 16 '23 06:11 Komald

Hi guys ) Any updates here? Or maybe it is possible to do it with formatter and parser with el-input?

dedli8 avatar Jul 23 '24 10:07 dedli8