-
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
Editor: Fix custom sources backwards compatibility for the pages post type. #17820
Editor: Fix custom sources backwards compatibility for the pages post type. #17820
Conversation
@@ -15,7 +16,9 @@ function useMetaAttributeSource( name, _attributes, _setAttributes ) { | |||
|
|||
if ( Object.values( attributeTypes ).some( ( type ) => type.source === 'meta' ) ) { | |||
// eslint-disable-next-line react-hooks/rules-of-hooks | |||
const [ meta, setMeta ] = useEntityProp( 'postType', 'post', 'meta' ); | |||
const { type } = useSelect( ( select ) => select( 'core/editor' ).getCurrentPost(), [] ); |
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.
getCurrentPostType
selector maybe?
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.
Sure, we'll need to change it later, but it's better for performance now.
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.
This makes sense to me. I didn't test but I trust the e2e test here.
Came into this issue via #17767. I'm still experiencing this issue with custom post type (in my case I have created a new post type When adding the block in posts/pages, everything is ok. This is the block plugin I'm using to reproduce the issue with WP 5.3.2. https://github.com/luuptek/bokun-wp |
Sounds like the core-data store is not bootstrapped correctly. Is |
How can I check that? |
Where is the code for the custom post edit screen? |
Gutenberg related stuff in here: https://github.com/luuptek/bokun-wp/blob/master/src/bokun-product/bokun-product.js ==> Meta data is registered via Custom post is added in theme , example via this:
|
Where is that custom post edit screen? |
Depends on custom post definition...in example above it would be in |
Sounds like your post type is missing https://developer.wordpress.org/reference/functions/register_post_type/ https://developer.wordpress.org/reference/functions/add_post_type_support/ |
Big thanks for pointing that! So custom post need to support |
I'm glad I could help! 😄 |
Fixes #17767
Description
This PR fixes the custom sources backwards compatibility filter's hook to take into account post types other than
post
.How has this been tested?
It was verified that adding blocks with meta sources to pages no longer crashes the editor and an e2e test was added to avoid regressions.
Types of Changes
Bug Fix: Meta sources no longer crash the editor if the edited post is not of post type
post
.Checklist: