[whatwg] <input type=number> without keyboard editing

Aryeh Gregor Simetrical+w3c at gmail.com
Tue Nov 2 12:57:51 PDT 2010


On Tue, Nov 2, 2010 at 4:46 AM, TAMURA, Kent <tkent at chromium.org> wrote:
> Do you have any idea of improved UI with the perfect conformance?

I don't understand this question.

On Tue, Nov 2, 2010 at 7:14 AM, Mounir Lamouri <mounir.lamouri at gmail.com> wrote:
> I'm not sure that disallowing out-of-range numbers would be the best
> implementation but if all implementations concur to that, maybe the
> specifications should reflect that and disallow out-of-range values like
> it's asking for valid floating point numbers value. For the moment,
> using a simple event handler should fix it.

If the user enters a value of 100 in <input type=number max=50>, then
it seems perverse to tell them "The maximum allowed value is 50" so
they have to go back and fix it.  It makes more sense to just
automatically clamp it to 50.  Unless the user happens to be
submitting the form before unfocusing the input, they'll see that it
got clamped and can fix it if that's wrong, but in practical cases it
should almost always be right to clamp out-of-range input, and to
round input that doesn't match the step.  (If the author doesn't like
it in some particular case, they can use a simple event handler
instead of max="".)

The spec is trying to say as little as possible about UI here, so that
browsers can experiment.  A browser where "Suffering from an
underflow"/"overflow"/"step mismatch" never occurred would be
conforming.  So I don't think we need implementations to concur at
this point -- they should be trying stuff out and seeing what works in
practice.  If they converge on particular conventions like this, then
the conventions can be added to the spec at that point.

As a data point on what non-HTML5 number inputs do, in Firefox 4.0b6
on Linux, in Preferences -> Advanced -> Network, there's a number
picker for how much cache space to use.  When I try to type 10000000
MB, it changes to 1611392 as I type.  Similarly, if I click
"Settings..." there to change how Firefox connects to the Internet,
and I try to manually type in a port above 65535, it clamps it as I
type.  If I try to type a negative number, the - keypress is just
ignored in both cases.  I would be fairly annoyed if in these cases I
was told "Please choose a value of 1611392 or less", since if I'm
typing 10000000 my intent is just to pick the maximum value anyway,
and and having to copy and paste or manually type it would be an
unnecessary pain.

This doesn't mean the spec should require the behavior at this point.
Implementations should ship with what they think the best UI is,
however that happens to integrate with the spec.  And if it does
actually conflict with the spec somehow, they should ask that the spec
be changed.  So this is a QOI issue right now, not a spec issue.

(Of course, as you point out, authors who are concerned with current
implementations can easily fix this particular issue with an event
handler.  But they probably shouldn't have to.)



More information about the whatwg mailing list