-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: prevent minus sign typing #794
base: master
Are you sure you want to change the base?
Conversation
4d8f73c
to
7e92d49
Compare
I'm wondering how effective it is to hide this fix behind a new argument that is Can we confidently say that we NEVER want to have a |
Do we want to handle copy pasting |
I think that's also something we would like too. I will add it to the issue and add it to the
I think this might be the best solution here indeed. It would solve the issue raised by @nicolasgasco while also fixing some cross-browser issues (i. e. Firefox does not do any prevention on characters) |
I agree. In that case do you want to explore it in this PR? |
The code would be simpler and less error prone if we didn't mix both |
Also we should make this a major version release, as we'd be dropping browser older browser support. Is |
822fd99
to
de8a93d
Compare
de8a93d
to
1b63560
Compare
Hi! Thanks a lot for all your inputs. I took every of them to improve this PR but the results of the exploration has been pretty disappointing for now. Input maskI tried to implement an input mask on it, but doing so on an I also thought about having a validation in the Do not use an arg and only prevent minus if not on first placeThis is a great idea but once again that did not succeed. Without possibility of using patterns, either on input or JavaScript, we could rely on An other approach could be to prevent minus sign to be typed in if Using
|
Aren't we keeping track of the input value anywhere? If not, how hard would it be to do it? If I understand correctly, the issue here is that we don't have a way to know the current value of the input. |
We are actually doing it in
It's here that there's the issue. The |
And can we have a reference of the value before the |
Yes it's possible ! However, it's not possible to know which position the character is typed in as However I also suggested this :
If the downside is considered as reasonable then we can move with this approach |
Description
This PR is a proposal to solve the issue #793.
The issue concerns an issue with input with type number that allows minus sign to be typed but can lead to empty values. To avoid this behavior, this PR proposes to prevent default behavior when user presses any
-
sign.As
-
sign has multiple keycodes (depending on keyboard layout, numpad, etc.) andkeyCode
is deprecated, this PR useskey
property instead.Also, we can imagine scenarii where prevent the usage of this symbol is not convenient, the removal is only available behind a argument
integerOnly
which is set tofalse
by default.