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
Form API: #size and #maxlength properties have no effect for '#type' => 'number' (ignored by browsers) #5434
Comments
@klonos wait a minute...
However, this is the wrong issue queue for that change. This issue should go to https://github.com/backdrop-ops/docs.backdropcms.org/issues |
Yes, the fixing of the Form API documentation belongs in https://github.com/backdrop-ops/docs.backdropcms.org/issues, but coming up with a workaround belongs in core 😉 |
Which workaround? ps: Size attribute for number input does work in Firefox. |
Still working on it and doing further research. Stay tuned 😉
Yeah, the screenshot I posted above was from Chrome on MacOS. Here's the same on Safari: Currently I'm having having some weird issues with logging into my local Lando site from Firefox (this didn't help), so I trust you on that @indigoxela 👍🏼 |
PoC PR (I quickly whipped up variable names without much thought): backdrop/backdrop#3896 Things work as expected mostly, but this is WIP and there are assumptions being made and some logic tweaking that needs to happen, but I'd appreciate any feedback. Tasks and things to research/test/consider:
|
I've added a commit that wraps the CCS workaround in Stopping here, as I think we need to decide:
|
Food for thought: Re
The fact that Firefox did not support it in the past, but does now, might be a sign that this could change in the future (the Mozilla Foundation is an important member of WHATWG). So for now, IMO we should remove both from the FAPI docs on number input, but wait with any workarounds until the currently (sort of) unclear situation gets clearer. |
Since it is still supported on Firefox, rather than removing it entirely from the FAPI Reference, how about (for now) a note in the description that says it only has support on Firefox? Having a visible note there, rather than it just vanishing, will also serve as a bit of a reminder to check later to see if the level of support has changed. |
I've removed #max_length from the number form element in FAPI, and added a note about #size. |
This is not a bug with Backdrop - adding
'#size' => 4
and'maxlength' => 3
does result in<input type="number" ... size="4" ... maxlength="3" ...>
, but no browser supports these, nor are there plans to support them. We should either remove them from the FAPI documentation, or figure out a workaround. I thought that perhaps using theattr()
CSS function (supported by all major browsers for years now), to set the field width depending on what was set for#size
.This issue becomes apparent when you specify
'#min'
but no'#max'
:[screenshots coming up]
Relevant sources around the web:
width
instead)width
instead)Backdrop Form API documentation that will need to be updated
#size
property: https://docs.backdropcms.org/form_api#size#maxlength
property: https://docs.backdropcms.org/form_api#maxlengthThe text was updated successfully, but these errors were encountered: