[wp-trac] [WordPress Trac] #59955: Block Hooks: Toggle removed if multiple anchor block instances exist, and one hooked block is deleted

WordPress Trac noreply at wordpress.org
Thu Nov 23 16:09:21 UTC 2023


#59955: Block Hooks: Toggle removed if multiple anchor block instances exist, and
one hooked block is deleted
-----------------------------+--------------------
 Reporter:  Bernhard Reiter  |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  low              |  Milestone:  6.5
Component:  General          |    Version:
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+--------------------
 If a block is an anchor block for one (or multiple) given hooked block(s),
 a 'Plugins' panel is displayed in the block inspector of the anchor block,
 with a toggle for each hooked block. (This was introduced by
 [https://github.com/WordPress/gutenberg/pull/52969 this Gutenberg PR].)

 The reason for this is to increase visibility of hooked blocks for the
 user, especially if they're editing a layout (i.e. a template, template
 part, or pattern) that already has some user modifications, as hooked
 blocks aren't currently auto-inserted into those. (It is planned to change
 that for WP 6.5, see #59646.)

 The toggles provide an easy way of inserting or removing a hooked block
 from its target location. The state of the toggle is determined
 heuristically: Essentially, if an instance of the hooked block in question
 is found in the "right" position, the toggle is set to enabled.

 That logic is a bit tweaked to be a bit more tolerant with regard to the
 locations that "count"; e.g. if a hooked block is expected ''after'' a
 given anchor block but is instead found ''before'', the toggle is also set
 to enabled.

 If the block isn't found anywhere at all in the template being edited, the
 toggle is set to disabled. If however the block is found somewhere in the
 template -- but not in the "correct" location -- it is assumed to be
 manually inserted; in this case, the toggle is removed altogether.

 (For the rationale behind this logic, see the discussion in
 https://github.com/WordPress/gutenberg/pull/52969.)

 This has one unwanted side effect: If a template has multiple instances of
 a given anchor block (and thus, multiple auto-inserted hooked blocks), and
 the user removes one hooked block, the toggle will be removed from the
 anchor block, as the other hooked blocks are assumed to be manually
 inserted.

 (This was first reported [https://make.wordpress.org/core/2023/10/15
 /introducing-block-hooks-for-dynamic-blocks/#comment-45867 here].)

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


More information about the wp-trac mailing list