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

Start input with a negative charachter #57

Open
ulfojebo opened this issue Nov 18, 2019 · 10 comments
Open

Start input with a negative charachter #57

ulfojebo opened this issue Nov 18, 2019 · 10 comments

Comments

@ulfojebo
Copy link

Tried using this package and it works really well.

Would like to discuss the posibility to add a "minus" charachter as the first input in a field.
The users of the system my team is building are used to this workflow when entering numbers.

I made it work on my machine but the question is if you think it should be entered here or if I should fork this project and make my own version for my specific needs.

Thanks!

@nbfontana
Copy link
Owner

Hi @ulfojebo!

There's this option: allowNegative - If true can input negative values. (default: true).

If you type 88 and then hit the minus button on the Keyboard the output becomes -88.00 (depending of your current config).

The minus charachter also appears for the user in front of the current prefix.

Is this a solution for your case?

@ulfojebo
Copy link
Author

I know that it is possible to enter negative numbers that way but it seems unnatural.
For now I have made a small change and made it work. When you enter the first minus the value is NaN but other than that I don't see any side effects.

@ulfojebo
Copy link
Author

changeToNegative(): void { if (this.options.allowNegative && this.rawValue != "" && this.rawValue.charAt(0) != "-" && this.value != 0) { this.rawValue = "-" + this.rawValue; } if (this.rawValue.charAt(0) != "-") { this.rawValue = "-"; } }

@betojsx
Copy link

betojsx commented Feb 27, 2020

+1 to @ulfojebo request
Also, thanks for the provided solution. Spent so many of hours searching for an alternative to avoid changing the core code but this seems to work.

@lambdadbmal
Copy link

I have a same issue.
I have tried @ulfojebo code and it works correctly.
I hope to merge his code into main trunk.
Thank you.

@dskibin
Copy link

dskibin commented Apr 8, 2020

Having the same issue. And of course -- it will be very helpful and made the lib more solid. Please merge it into main branch.

@dskibin
Copy link

dskibin commented Apr 8, 2020

@ulfojebo @betodasilva did you guys just clone the lib locally and made those changes in the changeToNegative? Or are there any other workarounds?

@willr79
Copy link

willr79 commented Apr 18, 2020

+1 to @ulfojebo request. I also have clients who are used to entering the negative sign as the first value when entering a negative currency value. This feature would absolutely make the lib more solid.

@slcoder
Copy link

slcoder commented May 30, 2020

changeToNegative(): void { if (this.options.allowNegative && this.rawValue != "" && this.rawValue.charAt(0) != "-" && this.value != 0) { this.rawValue = "-" + this.rawValue; } if (this.rawValue.charAt(0) != "-") { this.rawValue = "-"; } }

changeToNegative(): void { if (this.options.allowNegative && this.rawValue != "" && this.rawValue.charAt(0) != "-" && this.value != 0) { this.rawValue = "-" + this.rawValue; } if (this.rawValue.charAt(0) != "-") { this.rawValue = "-"; } }

great, this is working once we edit the core files, @nbfontana could you please take a look at this , it becomes a very important feature now.

@mhadji
Copy link

mhadji commented Apr 28, 2021

This is a deal-breaker for us too. I used the above fix and it worked. but modifying the library is not a sustainable solution.

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

8 participants