cchanxzy / react-currency-input-field

React component for an input field
MIT License
648 stars 118 forks source link

Issue #299 : Handle decimal values starting with ' . ' #340

Closed ng185115 closed 8 months ago

ng185115 commented 8 months ago

Issue https://github.com/cchanxzy/react-currency-input-field/issues/299

Built and tested.

ng185115 commented 8 months ago

Hi @cchanxzy

Can you please review this PR and if possible, could you consider merging this PR at your earliest convenience?

In this PR I have fixed it only for decimal numbers , if you want this to be applicable for other decimal separators as well I can modify this condition to

if (decimalSeparator && decimalSeparator !== '-' && value.startsWith(decimalSeparator)) { value = '0' + value; }

I'm excluding this ' - ' decimal separator as we doesn't know if that first character is intended to be the separator or negative sign.

cchanxzy commented 8 months ago

Thanks for your PR @ng185115!

In this PR I have fixed it only for decimal numbers , if you want this to be applicable for other decimal separators as well I can modify this condition to

if (decimalSeparator && decimalSeparator !== '-' && value.startsWith(decimalSeparator)) { value = '0' + value; }

I'm excluding this ' - ' decimal separator as we doesn't know if that first character is intended to be the separator or negative sign.

Yes I think that's a good suggestion, if you update the PR with your suggestion I'll be happy to merge it.

codecov-commenter commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (026329f) 100.00% compared to head (9907e29) 100.00%. Report is 1 commits behind head on main.

:exclamation: Current head 9907e29 differs from pull request most recent head 3c10ed1. Consider uploading reports for the commit 3c10ed1 to get more accurate results

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #340 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 15 15 Lines 411 413 +2 Branches 154 160 +6 ========================================= + Hits 411 413 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ng185115 commented 8 months ago

Hi @cchanxzy Made changes to support all decimal separators , Can you please review and merge it as soon as possible?

cchanxzy commented 8 months ago

Merged. Thanks @ng185115 !

ng185115 commented 8 months ago

Thanks @cchanxzy !! When can we expect this to be published ?

github-actions[bot] commented 8 months ago

:tada: This PR is included in version 3.7.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

cchanxzy commented 8 months ago

Ah just realised that the commit message didn't follow the semantic release convention, so it didn't trigger a release. That's on me, I should have checked.

I've just made a commit to trigger the release, so this commit will be included.

ng185115 commented 8 months ago

Thanks @cchanxzy !