Repository navigation
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the 🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. 📦 Bundle sizeSize Change: +196 B (0%) Total Size: 8.23 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome 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. applies the filtered form to the Quick Edit DataForm in
|
Adds a trash button to the block toolbar, in its own toolbar group immediately before the Options menu. It reads "Delete" for a single block and "Delete N blocks" for a multi-selection, and is rendered disabled (still focusable) when the selection cannot be removed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
b83b768 to
d006b2c
Compare
The Options > Delete menu item and the Move up/Move down toolbar buttons both surface their keyboard shortcut, so read the representation for `core/block-editor/remove` and pass it to the new button too. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`lint:changelogs` requires every unreleased entry to carry a Gutenberg pull request link, which was failing the CHANGELOG structure check. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
It's disabled on these blocks. My thinking was that it's worth having it always there for consistency. I'd rather users could see the button and have it not work, than the button be missing and them not understand why. The disabled button should help communicate that this cannot be deleted, which a missing button does not. |


What?
Adds a Delete button to the block toolbar of every block, using the
trashicon from@wordpress/icons. It sits in its own toolbar group immediately before the Options (⋮) menu.Why?
I've done a lot of user testing over the last few weeks. One of the behaviours I have seen with almost all users is that they don't use the keyboard to delete blocks, but instead they use the mouse. This means that to delete a block they have to look for the action in the kebab menu. This is problematic for two reasons:
How?
A new
RemoveBlockButtoncomponent renders aToolbarGroupwith a singleToolbarButton, rendered fromPrivateBlockToolbarjust beforeBlockSettingsMenu:Deletefor a single block andDelete %d blocksfor a multi-selection.disabled(still focusable,aria-disabled="true") whencanRemoveBlocks()is false, which covers locked blocks, content-only locked children and preview mode.removeBlocks( clientIds ), so selection moves to the previous block exactly as the Options → Delete menu item does.core/block-editor/remove, as the Options → Delete menu item and the Move up/Move down buttons in the same toolbar already do.The existing "Delete" item in the Options menu is unchanged; the toolbar button is an additional route to the same action.
The toolbar is shared, so the extensible site editor (v2) picks this up in the same change.
Two notes for reviewers:
.tsx; the test is.jsxwith one entry intools/eslint/suppressions.jsonforreact/jsx-filename-extension, as in Block Editor: Use UI Menu for bindings and variation transforms #81925 and Test: Run rendered browser behavior in Vitest Browser Mode #80995. A.tsxtest is not workable here:tsconfig.dev.base.jsonincludes test and story files, so a.tsxtest drags the src files it imports into that project and failsnpm run typecheckwith TS6307, sincepackages/block-editor/tsconfig.build.jsonis a progressive-typing allowlist that lists neither the component norsrc/store/index.js. Note that this also means the new.tsxis not type-checked by any project yet, the same asglobal-styles/text-shadow-panel.tsx; adding it to the allowlist needs the store listed first, which belongs in its own PR.keyboard-navigable-blocks.spec.jswalks the toolbar with ArrowRight and needed aDeletestep betweenMoreandOptions. The two specs that assume Options is the last toolbar button still hold, since the new group sits before it. Four other specs do query abuttonnamedDelete, but none are affected:font-library.spec.jsandtemplate-registration.spec.jsrun on screens with no block toolbar, andblock-removal.spec.jsandblock-notes.spec.jsscope the query to a dialog.Testing Instructions
Screenshots or screencast
The toolbar for a paragraph, with the new button before the Options menu:

Use of AI Tools
This PR was authored with Claude Code (Claude Opus 5). Claude wrote the component, its unit tests and the e2e helper update; I reviewed the result and the manual verification in the editor described above.