-
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
Remove one occurrence of incorrect usage of ItemGroup. #67427
Remove one occurrence of incorrect usage of ItemGroup. #67427
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: +3 B (0%) Total Size: 1.83 MB
ℹ️ View Unchanged
|
Flaky tests detected in bcbf51e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12116201721
|
That makes perfect sense @afercia. Let’s make sure the text is only displayed when any attribute is connected to the binding source. We should check whether |
It makes sense to me as well 🙂 It is already destructuring |
<Text as="p" variant="muted"> | ||
{ __( | ||
'Attributes connected to custom fields or other dynamic data.' | ||
) } | ||
</Text> |
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.
The fix outlined by @SantosGuillamot in #67427 (comment) would look like:
<Text as="p" variant="muted"> | |
{ __( | |
'Attributes connected to custom fields or other dynamic data.' | |
) } | |
</Text> | |
{ bindings.length && <Text as="p" variant="muted"> | |
{ __( | |
'Attributes connected to custom fields or other dynamic data.' | |
) } | |
</Text> } |
Prettier might have some opinions about formatting.
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.
Interesting. The ToolsPanle mechanism to toggle the visibility of this item assumes a div
element is in use:
gutenberg/packages/components/src/tools-panel/styles.ts
Lines 60 to 64 in b867a5f
export const ToolsPanelHiddenInnerWrapper = css` | |
> div:not( :first-of-type ) { | |
display: none; | |
} | |
`; |
I'm not sure I like it and it seems a bit fragile to me.
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.
The fix outlined by @SantosGuillamot in #67427 (comment) would look like:
Prettier might have some opinions about formatting.
I tested it a bit and it could use Object.keys( filteredBindings ).length
. However, that would make the help text appear after:
- An attribute is added to the ToolsPanel UI
- And a source value has been set to the binding.
Basically, the help text would appear only after a source has been set. Instead, on trunk it appears immedialy after an attribute is added. As such, I think we need to use the ToolsPanel mechanism, which assumes a div
element.
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.
I would personally argue that the behavior present in trunk
isn't entirely valid as you need to explicitly select a binding after exposing the attribute name in the UI, so it might be misleading as of today. Anyway, the proposed fix also works.
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.
Works as intended 👍🏻
* Remove one occurrence of incorret usage of ItemGroup. * Fix toggling visibility of the help text. Co-authored-by: afercia <[email protected]> Co-authored-by: gziolo <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: SantosGuillamot <[email protected]>
* Remove one occurrence of incorret usage of ItemGroup. * Fix toggling visibility of the help text. Co-authored-by: afercia <[email protected]> Co-authored-by: gziolo <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: SantosGuillamot <[email protected]>
See #67425
What?
The
<ItemGroup>
component should only contain<Item>
sub-components as it's intended to render alist
withlistitems
. This quick PR removes one incorrect usage.Why?
<ItemGroup>
should be used correctly, according to the documentation, only to render a list with listitems, i.e. a semantically and logically grouped set of items.It must not be used only for visual purposes.
How?
Use a paraagraph instead of an
<ItemGroup>
.Testing Instructions
content
attribute.Attributes connected to custom fields or other dynamic data.
is now rendered within a paragraph element and it's not wrapped within a div withrole=list
any longer.Testing Instructions for Keyboard
Screenshots or screencast