Make WordPress Core

Opened 8 months ago

Closed 7 months ago

#60856 closed defect (bug) (fixed)

Group block variations added via get_block_type_variations aren't loaded

Reported by: bacoords's profile bacoords Owned by:
Milestone: 6.6 Priority: normal
Severity: normal Version: 6.5
Component: General Keywords:
Focuses: Cc:

Description

Variations added to the core/group block via the get_block_type_variations filter do not show up in the block editor.

It seems to be a special case where the group block variations (row, stack, etc) are added later on and overwrite any variations added via this filter. Examining the block via the console (wp.blocks.getBlockTypes()) confirms that the variation doesn't exist at the time of the page load.

Change History (3)

#1 @joemcgill
8 months ago

  • Milestone changed from Awaiting Review to Future Release

Hi @bacoords, thanks for the report. It looks to me like the core/group block does not register any of its variations on the server and instead these are getting added to the block in JS in the editor. The server supplied block data can be observed by inspecting the output of the get_block_editor_server_block_settings() function.

The get_block_type_variations filter will allow you to modify the list of variations that are registered on the server, but if a block is adding variations at runtime, then any variations supplied from the server will overwritten. This is probably an oversight that will need to be corrected with the way the block editor handles merging server supplied variations with client supplied variations. This will need to be fixed upstream, so I'll open a related ticket on the Gutenberg repo.

In the mean time, I would suggest registering your variations in JS using these instructions.

#3 @joemcgill
7 months ago

  • Milestone changed from Future Release to 6.6
  • Resolution set to fixed
  • Status changed from new to closed

This has been fixed upstream in https://github.com/WordPress/gutenberg/pull/60832 and should be included in the next sync to core.

cc: @Mamaduka for any additional feedback.

Note: See TracTickets for help on using tickets.