Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#60572 new defect (bug)

block_core_navigation_render_inner_blocks loses caret for parent items

Reported by: anaid's profile anaid Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 6.4.3
Component: General Keywords:
Focuses: Cc:

Description

When we build a menu via the blocks editor the regular way, and create a parent menu items with a submenu, the parent menu item is (somehow) marked as a parent. It receives a caret automatically in Twenty Twenty Four theme.

When programmatically creating a menu via block_core_navigation_render_inner_blocks, the parent-child relationship is not marked automatically. There is no dropdown caret in the parent menu item.

Reproduction scenario:

  • Twenty Twenty Four theme
  • Go to Editor and manually create Navigation
  • Parent item "Post A"
  • Add a submenu
  • Child item "Post B"
  • View the website. Post A is parent, has a dropdown caret and Post B is below it

Now, do it programmatically via block_core_navigation_render_inner_blocks:

	function block_core_navigation_render_inner_blocks($items)
	{
		return new WP_Block_List(array(
			new WP_Block([
				'blockName'    => 'core/navigation-link',
				'attrs'        => ["label" => "Post A"],
				'innerBlocks'  => array(new WP_Block([
					'blockName'    => 'core/navigation-link',
					'attrs'        => ["label" => "Post B"],
					'innerBlocks'  => [],
					'innerHTML'    => '',
					'innerContent' => [],
				])),
				'innerHTML'    => '',
				'innerContent' => [],
			])
		));
	}

View the website. There is no dropdown caret applied to the parent post (Post A)

Change History (1)

#1 @anaid
5 months ago

Note, there's a typo in the above code sample. This bug persists even if you supply the correct blockName (i.e. 'core/navigation-submenu')

Note: See TracTickets for help on using tickets.