-
Notifications
You must be signed in to change notification settings - Fork 417
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
Allow users to enter out-of-bound numbers, outside of the minimumValue
and maximumValue
range
#543
Comments
I would suggest a different API. Leave the behaviour of The main advantage of this API is that someone migrating their interface from traditional number inputs to autonumeric can easily preserve the original behaviour. More generally, autonumeric will more closely resemble the widely used standard that everyone expects. People are familiar with controls that let you type in an invalid value but notify you of the problem. On the other hand, a control that suddenly reverts its value would be astonishing, confusing, and possibly lead to errors. Suppose a field contains a valid value but the user decides to change it to an invalid value, and while the field is still focused and containing this invalid value, they click submit. The field would blur before the submit and the user could unknowingly submit a value they explicitly didn't want. |
You're right, changing the invalid value back after the user modified it is bad UX. Having a specific However there are still many use cases to analyze since until now, AutoNumeric always assumed that the values stored in its element and internally were valid. We'd have to change all the event handlers ( If we go down this road, we could also modify the |
I don't think a new option is necessary. What I think that would be pretty reasonable, is to do kind of a 2 step validation:
Finally, do you think, from the end-user point of view, that would be "natural" to be allowed only to paste the value? In fact, that situation is the one which breaks the POLA. Got the point? Thank you. |
As stated in the previous comments, changing the value once the user blur it would be bad UX and would mostly confuse users.
What should happen if the user never enters a valid value? |
One solution could be to modify the Would that work for you guys? EDIT: Or, do not even add any new choice to the option, and set the |
@marco2250 your first step doesn't really make sense. Any digit could be a step towards a valid value. Maybe the user is trying to type 555555 or 1000000. The only exception is a 0 while the field is still empty. |
With all due respect, for now, what I know is that the minimumValue and maximumValue are useless, as they do not address real world situations. Anyway, again, congratulations for the component. |
Is there any progress on this? I really like autonumeric for all it does, but as already said, the minimumValue feature ist just useless if it behaves like this. Can someone suggest a good workaround to at least avoid submitting data via ajax that differs from the input the user sees? I use the the vue-autonumeric component. |
What do you mean by |
https://codepen.io/mannikj/pen/MxxoLx Although you are right that it would be quite hard to really submit that wrong data unintentionally, because the next user action will just reset the input instead of submitting it right away |
Turns out I'm a bit wrong here since we allow the user to delete the entire content of the field while the minimum value is higher than 0. Perhaps we should prevent that behavior. |
Did you look at the codepen? |
This is also tripping me up. I need a min value > 0. My allowed range is > 25 and <= 100. Why not check the value on blur because as other commenters have mentioned, you don't know the intention of the user - I want to enter 100 but 1 < 25 so I am not allowed to enter the first character. |
So, to sum up, to 'fix' the current behavior, we could:
This means this would affect how the
Thoughts? |
Please review the documentation, for now it's :
Which is clearly wrong. I agree, this option is useless and the documentation dangerous. You should remove this option, since you have already floatPos or intPos to define 0 as a minimum. Weird thing really. |
I'm not sure how you get to that conclusion, but the default minimum value really is -10 trillions. See the screenshot. |
If I put 20, or any positive number, user can't enter anything. So yes it's wrong. Not about the default value, but the behavior of this option doesn't allow to enter anything. |
@AlexandreBonneau I think that sounds reasonable. Additionally I would add that in any case (even if What do you think? |
overrideMinimumValueLimitation
option to allow temporarily entering values between 0
and minimumValue
when the latter is superior to zerominimumValue
and maximumValue
range
So, considering having However, I see the use case for being able to enter invalid numbers.
...or uses those:
I chose the latter, with the new This will allow, I hope, minimal changes to the codebase keeping the code as simple as possible. This way, most current users will not have to update their settings since the default won't change. Users wanting to be able to enter invalid numbers will be able to. Edit: Do note that the invalid state cannot be set on a contenteditable-enabled element (see the tests). |
@kaikun213 I'm not keen adding timeouts to AutoNumeric elements. You can already listen to the |
It took 2 years, but it's finally here ;) The latest AutoNumeric version |
Great, I think the documentation is still missing the new option http://autonumeric.org/configurator @AlexandreBonneau |
Not sure if this is the proper place, but with the latest version (4.6) I've solved what I believe that was intended with the following code:
|
While this setting can be helpful, such as being able to use CSS to highlight a bad value, that is still not really addressing the original problem. Or rather, it's just shifting the problem elsewhere. Here is a test case that is similar to my situation, where I want to have optional fields in a form, but still limit the range of values a user can enter. As such, it is a strange UI to indicate a problem with a field that isn't even required. Here is a test case I created that shows a lot of odd behaviors as a result of trying to use this new setting...
Really I just want to allow null/empty values in addition to the defined range (i.e. not treating empty as invalid). |
Currently, if a user sets the
minimumValue
option to a value superior to zero, it effectively prevent him to delete the input value, since it would mean therawValue
would be equal to0
.While this is exactly what the
minimumValue
option is for, I see a use case where users would want to be able to temporarily clear the element, in order to type their valid values.Allowing this will bring some side effects:
rawValue
will be updated with a potential incorrect out of range value while the user is typing it (the user would then need to manage those error cases),0
, but any values between0
and theminimumValue
minimumValue
set to1234
, then we would need to allow the user to type1
,12
and123
before finally accepting the correct value1234
.To that end, we would need to create a new option
overrideMinimumValueLimitation
(or something equivalent) set tofalse
by default, that would allow a user to input values between0
andminimumValue
in the element, and would then revert to the last good known value on blur if it's still equal out of range.This seems not trivial.
The text was updated successfully, but these errors were encountered: