Skip to content
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

cutTrailingZeros prop added to the component #614

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

IGrobenskiTT
Copy link

@IGrobenskiTT IGrobenskiTT commented Feb 11, 2022

added new prop => cutTrailingZeros (number) => if passed, then it will look for, and cut, ALL trailing zeros in the decimal part of the number, stopping at cutTrailingZeros decimal point.

So, in code, cutTrailingZeros is also used to determine the number of decimal places to leave intact when cutting trailing zeros. It's up to the developer, currently, to take care that the cutTrailingZeros prop's value isn't greater than decimalScale value (if such is used)

In case both decimalScale and cutTrailingZero props are used, if cutTrailingZero > decimalScale and fixedDecimal is used, it will display cutTrailingZero amount of decimals instead of decimalScale amount of decimals.

examples where this prop might be useful:
e.g. 123,456.780 and cutTrailingZeros = 2 (because let's say that, while cutting trailing zeros, we still do want to keep at least 2 decimals and cut all trailing zeros after 2nd decimal place) then the result will be => 123,456.78
but if 123,456.780 and cutTrailingZeros = 3 (because let's say that, while cutting trailing zeros, we still do want to keep at least 3 decimals and cut all trailing zeros after 3rd decimal place) then the result will be => 123,456.780 .

Github issue that this PR solves: #611

Works in all browsers

nikhil-varma and others added 4 commits November 8, 2021 23:42
cutTrailingZeros (number) => if passed, then it will look for, and cut, ALL trailing zeros , stopping at cutTrailingZeros decimal point. So cutTrailingZeros  is also used to determine the number of decimal places to leave intact when cutting trailing zeros . It's up to user, currently, to bear in mind the decimalScale value (if used) to not exceed its value. Currently, in case both decimalScale and cutTrailingZero props are used, if cutTrailingZero > decimalScale  and fixedDecimal is used, it will display cutTrailingZero  amount of decimals instead of decimalScale   amount of decimals.

examples where this is usefull:
 if 123,456.780 and cutTrailingZeros = 2 then the result will be => 123,456.78
but if 123,456.780 and  cutTrailingZeros = 3 then the result will be => 123,456.780 .
cut trailing zeros - on blur support added - now trailign zeros can be cut on Blur as well (previously it was only on change which is not always desired, now both events are possible!- use the one you need)
@Yusuf007R
Copy link

👍

@IGrobenskiTT
Copy link
Author

👍

can this be merged to DEV?

GTadeon added 2 commits March 8, 2022 12:51
flag allows you to chose between rounding (when using decimal scale) and no rounding. Default value is true (with rounding based on decimal and fixed scale passed). If false, it won't round. The rest of the logic still applies (cutting trailing zeros, other formattings..)
.
.
@Ostro
Copy link

Ostro commented Apr 8, 2022

i would really like to have this feature

@abenhamdine
Copy link

so useful !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants