-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Request: an alternative number control/input #9769
Comments
@robincornett |
Also, you're free to use any React component or self-made React component. Gutenberg just happens to use some and offer them for plugin authors. |
Thank you, I was able to get the TextControl set to a number input. Interestingly, the error about the attributes persists if the field is left empty unless I set it to be a string instead of a number for the attribute type, so it appears that setting the attribute type to number somehow makes it a required field. |
Yes that's default behavior, an empty string is not considered to be a number, you can try handling 0 or -1 as empty or have a switch control before the input to enable or disable the input |
Is your feature request related to a problem? Please describe.
I am working on converting a widget to be a block. There are a handful of number fields in my widget, but some of them are optional, and some have very large ranges (small or no minimum, very large maximum). The two issues I have are:
Error loading block: Invalid parameter(s): attributes
Describe the solution you'd like
I would like to have a NumberControl control with no range slider, and ideally it could accept a blank value.
Describe alternatives you've considered
I've currently got a RangeControl input working with the type set to
string
instead ofnumber
, but the slider is still problematic, so I probably really have to convert it to a TextControl. Either way, I have to add in an extra validation step to cast the value, if given, to an integer. So as an alternative, I can probably work around this, but I still would like a number field that is just a plain number input.If this is already an option that's available, I apologize--I looked through the handbook list and did not find it.
The text was updated successfully, but these errors were encountered: