-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Pattern Editing: Hide List View child blocks in Content panel #75007
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
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. |
| ); | ||
| return { | ||
| hasButton: blockNames.includes( 'core/button' ), | ||
| hasButtons: blockNames.includes( 'core/buttons' ), |
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.
Button blocks are now filtered out of the array of contentClientIds, so to solve the issue I changed the check to core/buttons instead.
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.
That's testing nicely for me with and without Buttons blocks in the section/pattern 👍
|
Size Change: +21 B (0%) Total Size: 2.98 MB
ℹ️ View Unchanged
|
andrewserong
left a comment
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.
| ); | ||
| return { | ||
| hasButton: blockNames.includes( 'core/button' ), | ||
| hasButtons: blockNames.includes( 'core/buttons' ), |
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.
That's testing nicely for me with and without Buttons blocks in the section/pattern 👍
* Hide List View child blocks in Content panel * Simplify code and add comments ---- Co-authored-by: talldan <[email protected]> Co-authored-by: andrewserong <[email protected]>


What?
Addresses some feedback from @andrewserong - #74843 (review).
The code currently has some hard-coded rules for List and Navigation blocks to exclude their children from the Content Panel:
gutenberg/packages/block-editor/src/components/block-inspector/index.js
Lines 166 to 168 in 6726612
gutenberg/packages/block-editor/src/components/block-inspector/index.js
Line 171 in 6726612
In this PR I'm formalizing the logic to specifically check for blocks that have List View support. Those that do have support will have child blocks not visible in the Content Panel.
Navigation block still ends up being an exception since it uses a custom implementation of List View and doesn't technically have List View support.
Why?
It shortens the content list to only those necessary. It also solves an issue where it looks like there are two selected blocks:

Now only Buttons is shown:

Testing Instructions