Skip to content
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

Fix registry update for different post types #200

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

kuuak
Copy link
Contributor

@kuuak kuuak commented Oct 13, 2023

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 and custom/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 the custom/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.

Avoid the block registry to be updated when opening the block editor.
If we do not have the same registered blocks per post types
the registry will be updated without all the available blocks.
⚠️ Disabling this, means that you have to manually hit the
"Update block registry" button in the settings page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant