-
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
Editor: Hide template part and post content blocks in some site editor contexts #58928
Editor: Hide template part and post content blocks in some site editor contexts #58928
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: -1.27 kB (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
b029242
to
ec052bb
Compare
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.
LGTM 👍
This is testing nicely.
✅ Could replicate original issue being able to access post content and template part blocks in site editor
✅ This PR prevents their access where appropriate
✅ Can still add post content block within a query block
export function useHideBlocksFromInserter( postType ) { | ||
useEffect( () => { | ||
/* | ||
* Prevent adding template part in the post editor. |
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.
* Prevent adding template part in the post editor. | |
* Prevent adding template part in the editor. |
Nit: Now this prevention is across both the post and site editors, is it worth making this comment a little more generic and not reference the post editor specifically?
Same for the other filter comment below.
Thanks for testing so quickly @aaronrobertshaw Work well for me in both post and site editors 👍🏻 In "edit template" mode for posts in both editors, I can add template parts, as well as post content block. |
Flaky tests detected in 9ad5632. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7913743091
|
Kinda thinking in addition to |
Related #52632
What?
In the post editor, we hide the "post content" block and the "template part" blocks in the default mode. But in the site editor, we also have the same modes but we don't do anything for these blocks, we just keep them around. This PR unifies that by moving this logic to the EditorProvider.
I think the existence of these filters is an indication that we're lacking some block API to define in which contexts (postTypes?) these blocks are allowed or not. That said, it's not entirely clear what such API should look like.
I also think the "template locked" mode should have the same treatment because you can't insert blocks outside post content there as well.
Testing Instructions
Try inserting "content" or "header" within posts or pages (either in post or site editors), you shouldn't be able to find these blocks in the inserter.