Skip to content

Try: Buttons — replace the on-canvas appender with a toolbar inserter - #82271

Closed
jeryj wants to merge 1 commit into
trunkfrom
try/buttons-toolbar-inserter
Closed

jeryj wants to merge 1 commit into
trunkfrom
try/buttons-toolbar-inserter

Conversation

@jeryj

@jeryj jeryj commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

What?

A prototype, opened as a draft to look at rather than to merge. It applies the same idea as #82270 (Navigation) to the Buttons block: no on-canvas appender, and "Add button" in the block toolbar when the Buttons block is selected.

Why?

Same question as #82270 — whether "add an item" reads better in the toolbar than as a + on the canvas. Buttons is a good second case because it is the simple version of the pattern: one allowed child, no submenu nesting, no entity loading. If the idea does not hold up here it is unlikely to hold up anywhere.

How?

The button is <Inserter isAppender> rather than a hand-rolled insert.

core/button is the only entry in the Buttons block's allowedBlocks and defines no inserter variations, so Inserter resolves a single block type. That means it renders as a one-click button instead of a popover, and InserterToggle derives the label from the block title — so "Add button" is not hardcoded, and no directInsert declaration is needed.

Going through Inserter rather than around it also preserves adjacent-sibling attribute inheritance (getSiblingBlockAttributes, #37904), which the on-canvas appender provided. That is not an assumption: buttons.spec.js already covered it, and the existing test passes unchanged apart from clicking the toolbar instead of the canvas. It is renamed from "…via the appender" to "…via the toolbar" to match.

Testing Instructions

  1. Insert a Buttons block and select the parent → "Add button" in the toolbar, no + on canvas.
  2. Click it → a Button is appended.
  3. Give the first button a text and background colour, select the parent, then "Add button" → the new button inherits both.
  4. Select a child Button → the inserter beside the parent selector still works as before.
  5. Empty the Buttons block, select it → "Add button" is still the way to add one.

Status

buttons.spec.js and navigable-toolbar.spec.js: 27 passing. inserting-blocks.spec.js: 47 passing.

Unlike #82270, there is no outstanding focus-management work here — the Buttons block has none of the custom focus handling the Navigation block built around its appender.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KkuJuaK9Vo54v3FmifLFt8

Removes the on-canvas appender from the Buttons block and adds "Add button"
to its toolbar, mirroring the Navigation prototype.

The button is `<Inserter isAppender>` rather than a hand-rolled insert.
`core/button` is the block's only allowed child and defines no inserter
variations, so `Inserter` resolves a single block type: it renders as a
one-click button and derives its own label from the block title, with no
hardcoded string and no need for `directInsert`.

Going through `Inserter` also keeps adjacent-sibling attribute inheritance,
which the on-canvas appender provided. The existing coverage for that now
inserts from the toolbar and still passes, so it is renamed to match.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KkuJuaK9Vo54v3FmifLFt8
@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Aug 31, 2026
@github-actions

Copy link
Copy Markdown

Size Change: +92 B (0%)

Total Size: 7.91 MB

📦 View Changed
Filename Size Change
build/scripts/block-library/index.min.js 371 kB +92 B (+0.02%)

compressed-size-action

@jeryj

jeryj commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor Author

@ellatrix - Same idea as the navigation but much simpler. Removes the on canvas appender, and adds "Add button" to the toolbar. Relies on the toolbar sibling inserter for adding new button blocks. If this is the right direction, I'll clean it up and get it ready for merge.

@ellatrix

ellatrix commented Sep 1, 2026

Copy link
Copy Markdown
Member

@jeryj Is this different from #81668? I'm generally all for moving it to the toolbar, and preferably in a systematic way. Would be good to have screenshots on the PR.

@jeryj

jeryj commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@ellatrix

Is this different from #81668

Nope, same idea. I didn't see that one. Sorry. Would it be helpful to have these smaller PRs split out or do you want to do it all in #81668? LMK how I can help. I think retiring renderAppender/simplifying insertion is a good project and want to see it happen :)

@jeryj jeryj closed this Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block library /packages/block-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants