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

Paste not working correctly #93

Open
BernardoSM opened this issue Mar 1, 2024 · 3 comments
Open

Paste not working correctly #93

BernardoSM opened this issue Mar 1, 2024 · 3 comments

Comments

@BernardoSM
Copy link

If you set decimals to 2 and paste 1000 value, will be converted to 10.00 and not 1000.00.

How can I fix this? I'd like to paste 1000 and show 1000.00

I'm using the component below:

<input
  v-model.lazy="modelValue"
  v-money3="config"
/>
@jonathanpmartins
Copy link
Owner

jonathanpmartins commented Mar 2, 2024

This is the expected behavior with arbitrary precision. You need to pass a string like this: "1000.00". I think what you need is to use the number modifier. From the docs:


Arbitrary Precision

In this release, some breaking changes have been introduced. Let's delve into the details:

v-money3 supports arbitrary precision through the use of BigInt. Arbitrary precision is only supported with v-model. When using v-model, ensure the input is provided as a string representation of a number (e.g., '12345.67'). If your precision is set to 2 and you provide a default v-model value of '55', it will be interpreted as '0.55'. To maintain the correct format, ensure you pass '55.00' when using v-model.

For most users, it's advisable to utilize floating-point numbers and adhere to the boundaries of Number. In such cases, employing v-model with the number modifier, or v-model.number, is recommended. However, this limits you to numbers smaller than 2^53 - 1 or 9007199254740991 (approximately nine quadrillion). Refer to MAX_SAFE_INTEGER for more information. For users employing v-model.number, integers and floats are intuitively understood. If your precision is set to 2 and you input a default v-model.number value of 55, it will be interpreted as 55.00. The same applies to 5.5, which will be rendered as 5.50.

More Examples


You are using the directive applied to a native html component. Will something like this help you?

<input 
    :model-modifiers="{ number: true }" 
    v-model.lazy="amount" 
    v-money3="config"
/>

@BernardoSM
Copy link
Author

Hey @jonathanpmartins thanks for the answer.

Unfortunately what I need is changing the "expected" behavior. For me doesn't make sense to paste 1000 (that is an integer) and display 10.00.

In my head if I paste 1000 should display 1000.00
If I paste 10 or 10.00, should display 10.00

Thanks again for the clarification!

@jonathanpmartins
Copy link
Owner

jonathanpmartins commented Apr 29, 2024

In my head if I paste 1000 should display 1000.00 If I paste 10 or 10.00, should display 10.00

Isn't this the default behavior with the number modifier set to true?
Is the default focusOnRight property set to false?

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

No branches or pull requests

2 participants