[wp-trac] [WordPress Trac] #59574: Blocks: No toggle shown for hooked blocks added via filter

WordPress Trac noreply at wordpress.org
Mon Oct 9 16:58:11 UTC 2023


#59574: Blocks: No toggle shown for hooked blocks added via filter
-----------------------------+-----------------------------
 Reporter:  Bernhard Reiter  |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  General          |    Version:
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 Per #59313, one core tenet of Block Hooks is to give the user the ultimate
 say in persisting or removing a hooked block. This is done by showing
 hooked blocks in the editor, and making them customizable by the user.

 Additionally, in order to aid visibility, a panel is added to the anchor
 block's block inspector with a list of blocks hooked to it, and toggles to
 enable or disable each of them.

 However, that toggle is currently only shown if the hooked block was added
 unconditionally (i.e. via the `blockHooks` field in `block.json`, or
 `registerBlockType()`). Conversely, the toggle is ''not'' shown if the
 hooked block was added via the `hooked_block_types` filter (#59424)).

 This is due to the how the toggles are implemented: The editor evaluates
 the block types endpoint's `blockHooks` field for a given anchor block
 (which corresponds to the `block.json`/block registration setting), and if
 it finds a hooked block in the specified location, it will show the toggle
 as enabled (and as disabled otherwise, unless the block is present
 elsewhere in the template).

 By its nature, that endpoint is "unconditional", i.e. in cannot provide
 the information which hooked blocks are present based on what template (or
 pattern) is being edited. A fix will thus require a different mechanism.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59574>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list