-
Notifications
You must be signed in to change notification settings - Fork 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
Updated default block categories for Automattic blocks #43198
Comments
Gutenberg ships with some compatibility mappings (PHP and JS) that will ensure legacy categories aren't broken. I'm slightly more concerned about using the new category names where we may not be on a recent editor version. I did some quick testing and it suggests if categories are updated before the plugin, the block won't be registered. Instead, you'll see a consol error like It may be best to go slow on this change. Legacy categories are compatible with updated categories, but updated categories are not compatible with the legacy ones. |
I asked if there are recommendations about how block authors should handle this in core-editor slack: https://wordpress.slack.com/archives/C02QB2JS7/p1591974296075900 |
Here's the recommendation: WordPress/gutenberg#19279 (comment) Namely, check if the category exists before you use it: var hasFormattingCategory = wp.blocks.getCategories().some( function( category ) {
return category.slug === 'formatting';
} );
wp.blocks.registerBlockType( 'my-plugin/my-block', {
category: hasFormattingCategory ? 'formatting' : 'media',
} ); Note that example checks for a legacy category. I'd have expected to check for the new category and fallback to the legacy category otherwise. |
This is what we're doing in CoBlocks (godaddy-wordpress/coblocks#1535); looking to go out in this week's release. |
Context: #43198 - Also add a helper function that can be used to check if old category names are still being used, and fallback to the old name if so. This should ideally be used in a ternary expression while setting the category name for blocks to provide the fallback old category name in order to support WP environments with older versions of Gutenberg. - Legacy categories were explicitly set to the new updated ones, following this example: https://github.com/WordPress/gutenberg/blob/84df4bd6082e7793a2befddb2a652cb42f445d21/packages/blocks/src/api/registration.js#L131-L135 - Some blocks might not have followed the example above and might have been moved to a category that made more sense for them
Context: #43198 - Also add a helper function that can be used to check if old category names are still being used, and fallback to the old name if so. This should ideally be used in a ternary expression while setting the category name for blocks to provide the fallback old category name in order to support WP environments with older versions of Gutenberg. - Legacy categories were explicitly set to the new updated ones, following this example: https://github.com/WordPress/gutenberg/blob/84df4bd6082e7793a2befddb2a652cb42f445d21/packages/blocks/src/api/registration.js#L131-L135 - Some blocks might not have followed the example above and might have been moved to a category that made more sense for them
Context: #43198. - Also add a helper function for FSE blocks that can be used to check if old category names exist in the store and fall-backs to an older version(s) otherwise. This function should be used when the updated category is a completely new category being introduced by a new version of Gutenberg. You then pass this new category + the older categorie(s) that will be tried in sequence if the previous one was not found. - Tweaked the FSE Jest configuration to support TypeScript.
Context: #43198. - Also add a helper function for FSE blocks that can be used to check if old category names exist in the store and fall-backs to an older version(s) otherwise. This function should be used when the updated category is a completely new category being introduced by a new version of Gutenberg. You then pass this new category + the older categorie(s) that will be tried in sequence if the previous one was not found. - Tweaked the FSE Jest configuration to support TypeScript.
Context: #43198. - Also add a helper function for FSE blocks that can be used to check if old category names exist in the store and fall-backs to an older version(s) otherwise. This function should be used when the updated category is a completely new category being introduced by a new version of Gutenberg. You then pass this new category + the older categorie(s) that will be tried in sequence if the previous one was not found. - Tweaked the FSE Jest configuration to support TypeScript.
* Change the category of FSE blocks from legacy to the updated ones Context: #43198. - Also add a helper function for FSE blocks that can be used to check if old category names exist in the store and fall-backs to an older version(s) otherwise. This function should be used when the updated category is a completely new category being introduced by a new version of Gutenberg. You then pass this new category + the older categorie(s) that will be tried in sequence if the previous one was not found. - Tweaked the FSE Jest configuration to support TypeScript. * Fix workflow logic to not run phpcs for deleted files * Remove fallback to layout from button and login-button from premium-content The fallback was causing these blocks to appear in older versions of Gutenberg where the `design` category was not available. Until here, all good. However, they were all er'ing upon insertion. We thought it would be better to rollback this change for now.
With Automattic/block-experiments#110 handed off and everything else merged, I think we're good to close this. Thanks @fullofcaffeine! |
In Gutenberg 8.3.0 we have updated default block categories (WordPress/gutenberg#19279).
Those are now running on edge sites, and within a week on production.These new categories are now in production.We'll need to match Automattic block categories with new categories.
We'll also need to keep supporting old default categories for Atomic sites which might not run Gutenberg.
The tasks needs:
full-site-editing
plugin (FSE: Update blocks categories #43670)wpcom-blocks
(https://github.com/Automattic/wpcom-blocks/pull/178)block-experiments
(Update blocks categories block-experiments#110)*We announced this initiative and asked for feedback here: pbAok1-18e-p2
Screenshots
The goal is just to illustrate what the change is about and how it reflects in the UI. If you'd like to know all categories that have been changed, check the PRs linked above.
image-compare
(Jetpack)a8c/layout-grid
(block-experiments)The text was updated successfully, but these errors were encountered: