[whatwg] More stepUp() and stepDown() comments (was: Re: Forms-related feedback)
ian at hixie.ch
Wed Jan 30 11:21:40 PST 2013
On Wed, 30 Jan 2013, Mounir Lamouri wrote:
> > Also, note that per the new spec if stepUp() or stepDown() are called
> > with an argument that isn't 1, it's ignored if the value isn't on a
> > valid step. So in the example above, if value=22 and you call
> > stepDown(5), it only goes down to 20, not 10. Is that ok?
> Why? That is an arbitrary limitation.
Mounir and I discussed this on IRC, but we didn't have enough data to come
to a conclusion.
Mounir's argument, which is compelling in its simplicity, is that
...should be equivalent to:
for (var i = 0; i < n; i += 1)
That is to say, that stepUp() should be linear.
My argument is rooted more in terms of how this API would be used to
implement UIs. I argue that if you have a physical interface that allows
you to move a needle a little or a lot, but the needle is out of
alignment, the first thing you do regardless of whether you are going to
push the "move a little" or "move a lot" button would be to get the needle
in alignment. Since there's no way to "hit" a widget, all of the widget's
controls, when the value is out of range or out of step, should first act
as if you had wacked the widget to get its value into range, and only
then, if you push the buttons again, should they act as labeled.
> > Also, if you call it as stepDown(-2), it goes down to 20, it's not left at
> > 22, because the argument is ignored and the method itself is used to
> > determine the direction if we're not on step. Is that ok?
> > Similarly, if you're at 10, and you call stepUp(1), it goes to 20, but if
> > you call stepUp(2), it stays at 10, because 30 is out of range (max 21).
> > Is that ok?
> No, it should go to 20 too.
> I think we should add a step between step 5 and step 6 that says:
> "If value is less than minimum and stepDown() was invoked or if value is
> greater than the maximum allowed value and stepUp() was invoked, abort
> these steps."
> Then, step 7 and 8 should be changed to:
> "7. If the element has a minimum, and value is less than minimum, set
> value to the minimum."
> "8. If the element has a maximum, and value is greater than the maximum
> allowed value, set value to the maximum allowed value."
> I also believe we should define the "maximum allowed value" as:
> "If an element has a maximum, its maximum allowed value is the maximum
> if the maximum subtracted from the step base is an integral multiple of
> the allowed value step. Otherwise, it is the nearest value that, when
> subtracted from the step base, is an integral multiple of the allowed
> value step and that is less than the maximum."
> Those changes would make the following snippet work as expected:
> data:text/html,<input type='number' min=-10 step=10 max=100 value=-100>
> If you call stepDown() on this, you would expect that nothing happens
> because there are clearly nothing that can be done. However, stepUp()
> should clamp to the first allowed value.
> In addition, it will make sure we clamp to the maximum allowed value if
> we do stepUp(1000) instead of doing nothing.
If we believe my skeuomorphic argument, then in this latter example, you
would expect the button to change the value to -10.
Does anyone have any examples of UIs that give "page up" and "page down"
controls to change values that can also be set to out-of-range values so
we can study how existing UIs handle this?
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg