[wp-trac] [WordPress Trac] #60756: Block Hooks: Toggle (re-)inserts hooked block in wrong position (if added by filter)
WordPress Trac
noreply at wordpress.org
Tue Mar 12 13:59:51 UTC 2024
#60756: Block Hooks: Toggle (re-)inserts hooked block in wrong position (if added
by filter)
-----------------------------+-----------------------------
Reporter: Bernhard Reiter | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
As of [https://github.com/WordPress/gutenberg/pull/59396 this change],
Block Hook toggles are displayed for hooked blocks that were added by a
filter (rather than during block registration), ''if the containing
template or template part has had user modifications''. (Displaying the
toggle also for ''un''modified templates/parts is the subject of #59574,
see especially https://core.trac.wordpress.org/ticket/59574#comment:13.)
There is still one more problem with these toggles: If the user disables
the toggle to remove the hooked block, and then re-enables it to re-insert
the latter, it's not possible for the client to infer ''where'' to insert
it. Instead, it simply defaults to (re-)inserting it ''after'' the anchor
block.
The reason is that once the hooked block is removed, no information about
its position relative to its anchor block is available. The only available
information is the `ignoredHookedBlocks` metadata attribute on the anchor
block, which is an array of hooked block type names (e.g.
`["core/loginout","mycommerce/shopping-cart"]`). They do however not
include the relative position of these hooked blocks. (This was considered
in the original ticket #59646 for enabling Block Hooks in modified
templates/parts, but ultimately dismissed.)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60756>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list