-
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
Query Loop block: Convert the post content type setting to a ToggleGroupControl if there are few items #63375
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. |
Size Change: +64 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
Have you tested with third-party post types available as well? How well does this scale? |
I have tested it with the third-party post types provided by the |
packages/block-library/src/query/edit/inspector-controls/index.js
Outdated
Show resolved
Hide resolved
packages/block-library/src/query/edit/inspector-controls/index.js
Outdated
Show resolved
Hide resolved
This is looking good to me. The spacing is a bit off maybe so let's see what designers say. |
Another quick check: would a ToggleGroup work better here? If it's only ever for two items max? |
ToggleGroup would be nice if it were two, but we don't want many edgecases, i.e. togglegroup, then radios, then dropdown. Radios work okay as far as translatability of long strings, though. So if the PR is mainly to optimize for the case of "Post" and "Page", I'd go segmented control as Rich suggests: it seems to be the 80% case, and the specific design of the segmented control better affords the very verbose help-text that sits right below the box. |
Since built-in post types cannot be unregistered via |
Here's an attempt with a Grabacion.de.pantalla.2024-07-12.a.las.12.06.57.mov |
Looks good. Can you make the segmented control full width? I.e. 100% width of the inspector panel. |
Gotcha. Even better 👍 Grabacion.de.pantalla.2024-07-12.a.las.12.33.30.movThe "Sticky posts" dropdown has a fixed number of three items. Should I follow up later by converting it to a ToggleControlGroup as well for consistency? |
If we believe the 3 items can fit in a segmented control even in translations, definitely a good choice. Otherwise I'd probably keep it a dropdown. "Only" is a bit of a weird term, though. Separately, we can add the |
Nice work! |
Flaky tests detected in 67cfd4e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9907035736
|
packages/block-library/src/query/edit/inspector-controls/index.js
Outdated
Show resolved
Hide resolved
I wold prefer not to add such a feature to In my opinion, low-level components should provide a focused, flexible, and modular primitive, thus allowing some powerful composition patterns. Composing those puzzle pieces together should be done externally by the consumer of the package (cc @WordPress/gutenberg-components ) |
eb354b6
to
4c871cd
Compare
…oupControl if there are few items (WordPress#63375) Co-authored-by: priethor <priethor@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org>
Closes #63374.
What?
When there are fewer than three items, this PR converts the Query Loop's post content type inspector control to a
ToggleGroupControl
instead of using theSelectControl
.It also changes the label copy from
Post type
toPost content
for accuracy and applies__next40pxDefaultSize
to this and other Query Loop inspector controls.Why?
Select controls are useful for avoiding visual clutter when there are many options to choose from. However, they require an extra click and do not offer visual improvements when there are few items.
How?
By using a
ToggleGroupControl
instead of aSelectControl
when there are fewer than three items.Testing Instructions
Inherit query from template
setting.Post content
option will appear using a ToggleGroupControl withPost
andPage
as options.Screenshots or screencast
Grabacion.de.pantalla.2024-07-10.a.las.19.18.10.mov