Fix registry update for different post types #200
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If we do not have the same registered blocks per post types the registry will be updated without all the available blocks.
Here a basic example:
If I have 3 available blocks
core/heading
,core/paragraph
andcustom/section
.Let's assume I do not need the
custom/section
in the Post post-type, therefore I have some custom code to checks if the current post type in the editor is post, and if so I unregister thecustom/section
block.This means that when the
registerBlockRegistryUpdate
plugin run, it retrieves the available blocks, in this situation two blocks, and make the block registry to be updated with these 2 blocks.But now I if I open the editor to edit a page, my custom code does not unregister the section block, and the
registerBlockRegistryUpdate
updates the registry with 3 blocks.This is really a basic example where I have 1 missing block in the registry if the last content update was a Post.
But in my real usage I have more than 100 available blocks that can be available for one or many post types. I end up with sometimes 22 blocks in the registry, or 50 or more than a 100 when I manually hit the "Update block registry" button in the setting page.
My quick fix is then to I disabled the two editor plugins which updated the block registry with the current post type registered blocks.