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 clean up registration of blocks #30

Merged

Conversation

fabiankaegy
Copy link
Member

In the current iteration there are a few manual steps that need to be done in order for an interactive block to work correctly that are not how these blocks will work in the future. This PR updates the flow so that all these steps get handled automatically by the plugin instead of manually by the block author.

This PR updates it so that any block that has supports.interactivity set to true will automatically get the wp-directive-runtime script dependency added to any viewScript scripts.

Additionally it also auto registers all the blocks. So when you add a new block you don't need to touch any files outside of the blocks folder itself.

@michalczaplinski
Copy link
Collaborator

That's awesome, thanks Fabian! 👏

Just FYI - we have on the roadmap the ability to automatically detect if a block is using directives: WordPress/block-interactivity-experiments#126.

This can be done using the HTML_Tag_Processor. So, just by virtue of using directives your block is automatically an "interactive" block and we can then enqueue the relevant scripts. With that functionality in place we might not even need the "supports": { "interactivity": true } in the block.json of the interactive blocks.

@michalczaplinski michalczaplinski merged commit 4433c97 into WordPress:main Mar 21, 2023
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.

2 participants