-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
DataForm: Fix SelectControl size and spacing #64324
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
The other small thing I'm noticing in the screenshots above is that the padding left of the first control (TextControl) is different than the other controls (NumberControl and SelectControl). I think this comes directly from the underlying components. So I'm wondering if you folks are aware of it cc @tyxla @mirka |
This issue has been reported in #57394 |
__next40pxDefaultSize | ||
__nextHasNoMarginBottom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem if this PR merges first, but FYI these props are being added in bulk to all in-app SelectControls in #64283.
Not sure if this requires a separate Github issue or it can be discussed in this thread here... Looking through the docs in data form, the form elements seem like they could be made a little more intuitive. https://wordpress.github.io/gutenberg/?path=/docs/dataviews-dataform--docs. It looks like when trying to generate a dropdown, you pass the 'type' in as 'text' and then it creates a dropdown. It's not clear how to create other elements that use multiple options such as radio and checkboxes. I think the 'type' should match what you want to output, in the case of the documented examples the 'type' for author and status should be something like 'select'. If you wanted the status to be radio you'd do something like 'radio'. We should also consider accessibility with the more advanced types such as checkboxes and radios. There should be additional properties for things like 'legendLabel' so things can be wrapped in valid markup with a legend. Lastly, for 'type' of 'integer', I wonder if 'number' is more appropriate since that's the actual type in html5 so as a consumer of the component I'd naturally think of 'number' as the value and not 'integer'. |
We definitely didn't invest much in docs yet as it's bit early but the idea is that if you pass
Obviously, we'd need this kind of customization but we're starting very small and iterating/adding controls types (radio, toggles, ...) as we implement UIs in Core (quick edit focus for now).
I agree that we need ways to "group" fields... I've heard a few things already:
We also need support for things like "description", "help" for fields.
We discussed this with @oandregal already, I think it's not settled but André had some good arguments. |
The Of course, we've just started. We will need to build more nuances to decide whether to render a radio or a select, how to group fields together, etc. |
The REST types are the way they are because they’re independent of form data. You can send data derived from any source to REST and have it validated which is why “Type” works well in that context. When defining “Type” in DataForm, it’s confusing because html form elements have the “type” attribute. Also it’s not intuitive or obvious what input will be output when I put in “type” of “integer”. What if I want a drop down of elements and validate all as integer? I think validation, sorting, all that is totally separate from “Type”. Maybe we should do “validateAs” as a separate property and that’s what gets “integer”. I know this is early and documentation isn’t done but that doesn’t mean we can’t properly account for future elements. Using type “select” for drop downs now helps make this easier to use and starts to give a pattern for the future. Making text output select now seems like we will have to either make a breaking change later or have a not very intuitive experience as a dev. Documentation is nice but even better is when documentation is not required because something is so easy and intuitive. |
Related #59745
What?
Small PR to improve the consistency of the size and spacing of the controls that are generated by the DataForm component. Specifically this fixes the size and spacing for the "select" control for string fields.
Before
After
Check the size and spacing of the status control.