Skip to content

Blocks: support a default block in block type settings - #81235

Closed
ellatrix wants to merge 8 commits into
trunkfrom
add/block-type-appender
Closed

ellatrix wants to merge 8 commits into
trunkfrom
add/block-type-appender

Conversation

@ellatrix

@ellatrix ellatrix commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

What?

Moves the defaultBlock option of InnerBlocks/useInnerBlocksProps into block type settings, keeping its name and shape ({ name, attributes }, since #81250 removed attributesToCopy). The option is deprecated and still overrides the setting. Step 3 of #81239.

This PR previously introduced an appender block type setting; that approach is reverted in place. Which appender a block shows derives from its default block in later steps, so the block type fact to move is the default block itself.

Why?

What a container creates when you append into it is a property of the block type, currently only expressible at render time. Declaring it on the block type lets the store and editor reason about it without mounting the block: the appender, the inserter, and the planned empty-state work (#81231) all key off it.

How?

  1. defaultBlock block type setting. Typed and documented in @wordpress/blocks; no registration changes, mirroring the template setting.
  2. Resolution in InnerBlocks. When no defaultBlock option is passed, the block type's setting feeds the block list settings; nothing changes store-side. Passing the option warns.
  3. Migrations. accordion, buttons, columns, gallery, list, navigation, navigation-link, and navigation-submenu declare their default block on the type. directInsert is untouched and stays an option for now. The accordion item's directInsert: true is removed: it never declared a default block, so it never did anything.

Testing Instructions

  1. In a Buttons block, click the appender or press Enter at the end of a button: a button is added with copied styles, as on trunk after Block editor: unify what a new sibling block inherits #81250.
  2. In an Accordion block, use "Add item": an accordion item is added directly.
  3. In a List block, the appender adds list items directly.
  4. Insert images into a Gallery and columns into Columns via their flows: unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GQNdFF1FUU9JXfNGZev2na

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Blocks, [Package] Block library, [Package] Block editor.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions github-actions Bot added [Package] Blocks /packages/blocks [Package] Block library /packages/block-library [Package] Block editor /packages/block-editor labels Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ellatrix <ellatrix@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Size Change: +7 B (0%)

Total Size: 7.81 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 434 kB +79 B (+0.02%)
build/scripts/block-library/index.min.js 356 kB -72 B (-0.02%)

compressed-size-action

@ellatrix ellatrix changed the title Blocks: support block appenders in block type settings Blocks: support a default block in block type settings Aug 5, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Flaky tests detected in 20b2df0.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/31058630700
📝 Reported issues:

ellatrix and others added 8 commits August 5, 2026 19:57
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQNdFF1FUU9JXfNGZev2na
The button appender cases each gate on their own conditions, so they
keep the renderAppender option for now and migrate in a follow-up.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQNdFF1FUU9JXfNGZev2na
The appender derives from the default block instead; see the children
namespace introduced next.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQNdFF1FUU9JXfNGZev2na
Moves the defaultBlock option of InnerBlocks to the block type, where
the appender and inserter machinery can read it without mounting the
block. The option is deprecated and still overrides the setting. Also
removes the accordion item's inert directInsert, which never had a
default block to insert.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQNdFF1FUU9JXfNGZev2na
The block type setting is readable from the block name, so it must not
go through updateBlockListSettings; only the deprecated option does.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQNdFF1FUU9JXfNGZev2na
Enter on a block with bound attributes inserts an adjacent default
block; the actions read the block list settings only, so they lost the
default when it moved to the block type.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQNdFF1FUU9JXfNGZev2na
It no longer exists after the sibling attributes unification.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQNdFF1FUU9JXfNGZev2na
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Package] Blocks /packages/blocks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant