Make WordPress Core

Opened 3 months ago

Closed 4 weeks ago

#59955 closed defect (bug) (reported-upstream)

Block Hooks: Toggle removed if multiple anchor block instances exist, and one hooked block is deleted

Reported by: bernhard-reiter's profile Bernhard Reiter Owned by:
Milestone: Priority: low
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

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 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 here.)

Change History (2)

#1 follow-up: @Bernhard Reiter
4 weeks ago

PR available to fix this over in the Gutenberg repo: https://github.com/WordPress/gutenberg/pull/57928

#2 in reply to: ↑ 1 @Bernhard Reiter
4 weeks ago

  • Milestone 6.5 deleted
  • Resolution set to reported-upstream
  • Status changed from new to closed

Replying to Bernhard Reiter:

PR available to fix this over in the Gutenberg repo: https://github.com/WordPress/gutenberg/pull/57928

This has been merged. I'm thus closing this ticket; setting to reported-upstream seems like the best fit (as it reflects that the issue had to be addressed in a different codebase, and Core will eventually "inherit" the fix).

Note: See TracTickets for help on using tickets.