Block Hooks: Incorrect placement in the parent container for hooked blocks #54307
Labels
[Feature] Block API
API that allows to express the block paradigm.
[Priority] High
Used to indicate top priority items that need quick attention
[Status] In Progress
Tracking issues with work in progress
[Type] Bug
An existing feature does not function as intended
Description
Every block that has inner blocks also has some wrapping HTML element. The way hooked blocks are currently implemented is that it puts the injected block at exactly first or last place in the parsed block, which happens to be outside of the wrapping element. A simplified example based on REST API response that shows the issue:
It should be withing the
main
tag instead:Step-by-step reproduction instructions
core/comment-template
block.Screenshots, screen recording, code snippet
The configuration used for the Like Button:
The same issue exists for
firstChild
andlastChild
. Everything works correctly forbefore
andafter
positions.The issue was hard to discover because the way it's presented in the block editor is perfectly valid:
The REST API endpoint contains the hooked block as expected, at least when you don't check it with enough attention:
The issue is easier to spot when checking the source of the webpage because the block gets printed after (or before when using
firstChild
) the closing tag for the target parent block:It's hard to tell by looking at the page:
Well, until you use source inspector:
Environment info
The latest Gutenberg version.
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: