Make WordPress Core

Opened 5 months ago

Closed 5 months ago

#60755 closed defect (bug) (duplicate)

Block Hooks: Toggle (re-)inserts hooked block in wrong position (if added by filter)

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

Description

As of 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 unmodified 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.)

Change History (1)

#1 @Bernhard Reiter
5 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #60756.

Accidentally filed the same ticket twice (due to a database error upon submitting the first one). Closing.

Note: See TracTickets for help on using tickets.