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

[forms] Number input intrinsic size. #10390

Open
emilio opened this issue Jun 4, 2024 · 15 comments
Open

[forms] Number input intrinsic size. #10390

emilio opened this issue Jun 4, 2024 · 15 comments

Comments

@emilio
Copy link
Contributor

emilio commented Jun 4, 2024

What is the issue with the HTML Standard?

We just found out that Blink and WebKit have some magic default sizing behavior for <input type=number>, derived from the min / max attributes:

<input type="number"> | <input type="text"> <br>
<input type="number" size="4"> | <input type="text" size="4"> <br>
<input type="number" min="0" max="100"> | <input type="text"> <br>

In particular:

  • size seems to be ignored.
  • if you have both min and max, and the step is not any, then you infer a size based on "sign + max digits + dot (if needed) + decimals (if needed)". The logic seems to come from WebKit so it matches in both.

So, I think inferring size from min / max if possible makes sense. However, I think disregarding size otherwise feels wrong?

My proposal would be to:

  1. Standardize the WebKit/Blink min/max behavior. It's not pretty but it makes sense I guess.

  2. Standardize the Firefox size behavior (that is, still honor size if present, probably with higher priority than min/max, but I guess either order works).

Would something like that feel palatable? The first is probably a requirement for compat, but <input type=number size="N"> getting completely ignored seems unfortunate otherwise.

@emilio emilio added the agenda+ To be discussed at a triage meeting label Jun 4, 2024
@emilio
Copy link
Contributor Author

emilio commented Jun 4, 2024

cc @mfreed7 @josepharhar @annevk

@mfreed7
Copy link
Contributor

mfreed7 commented Jun 4, 2024

Icky.

So the spec and MDN both say size doesn't apply to number inputs. I'm not sure if there was logic behind that decision? It does seem reasonable to me to expand it to include number inputs, but yeah I'd be concerned about compat.

@emilio
Copy link
Contributor Author

emilio commented Jun 4, 2024

@mfreed7 the compat issue you linked is tangential to whether number inputs respect the size attribute. I've never seen a compat issue on Firefox for respecting size.

@mfreed7
Copy link
Contributor

mfreed7 commented Jun 4, 2024

@mfreed7 the compat issue you linked is tangential to whether number inputs respect the size attribute. I've never seen a compat issue on Firefox for respecting size.

Right, of course. I just meant that changing the layout size of <input type=number> based on attributes can be a source of breakage. The Firefox issue was about min/max, but I don't see a reason, a-priori, to assume that changes to the width based on size won't break something too. I don't think we have any use counter data measuring <input type=number size> usage. Do you have any data on this?

@emilio
Copy link
Contributor Author

emilio commented Jun 5, 2024

I do not. Happy to add it and come back here in a couple months if you want (but changing based on size is what I'd expect off-hand since that's what happens on most other text inputs)

@annevk
Copy link
Member

annevk commented Jun 5, 2024

cc @pxlcoder @nt1m

@mfreed7
Copy link
Contributor

mfreed7 commented Jun 5, 2024

I do not. Happy to add it and come back here in a couple months if you want (but changing based on size is what I'd expect off-hand since that's what happens on most other text inputs)

Cool, thanks! I agree with the sentiment that it would make sense for size to work on number inputs, if it's web compatible.

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jun 6, 2024
@past past removed the agenda+ To be discussed at a triage meeting label Jun 6, 2024
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jun 6, 2024
See whatwg/html#10390 for the spec issue.

Differential Revision: https://phabricator.services.mozilla.com/D212545

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1898214
gecko-commit: 7fdc398eba165528948b2abf22341424a4d6cd3e
gecko-reviewers: smaug
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jun 7, 2024
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jun 7, 2024
See whatwg/html#10390 for the spec issue.

Differential Revision: https://phabricator.services.mozilla.com/D212545

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1898214
gecko-commit: 7fdc398eba165528948b2abf22341424a4d6cd3e
gecko-reviewers: smaug
@annevk
Copy link
Member

annevk commented Jun 7, 2024

Reading this thread again I'm not sure about doing 2 as size would be a presentational attribute here.

@dbaron
Copy link
Member

dbaron commented Jun 7, 2024

I think size is at the border of presentational versus semantic: as a semantic you could see it as saying "this is the number of characters that the input's value should be able to hold".

@annevk
Copy link
Member

annevk commented Jun 7, 2024

That's fair and it seems like we haven't attempted to make it non-conforming generally, but then the proposal would have to include:

  1. Make size conforming to use for <input type=number>.

@emilio
Copy link
Contributor Author

emilio commented Jun 7, 2024

Sure, consider that part of the proposal :)

ErichDonGubler pushed a commit to erichdongubler-mozilla/firefox that referenced this issue Jun 10, 2024
ErichDonGubler pushed a commit to erichdongubler-mozilla/firefox that referenced this issue Jun 10, 2024
@emilio
Copy link
Contributor Author

emilio commented Jul 4, 2024

So the spec seems to account for something like this here. I still think that the size attribute would make sense for number inputs, and if people are on board it'd be a matter of editing that section. Happy to write such a patch.

@annevk
Copy link
Member

annevk commented Jul 5, 2024

Should it end up with a different width because of the inline number manipulation buttons? I noticed that in Firefox data:text/html,<input type=number value=3 size=1> currently ends up with an obscured value.

cc @whatwg/forms

@emilio
Copy link
Contributor Author

emilio commented Jul 5, 2024

Yes, that is fixed already fwiw: https://bugzilla.mozilla.org/show_bug.cgi?id=1905743

@annevk
Copy link
Member

annevk commented Jul 5, 2024

That's what you get for testing with a July 2 Nightly.

I think it's reasonable to add this, but I don't think editing just that section is enough. You also need to make size a conforming attribute for this control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants