Repository navigation
Block API: Scope variation keyboard shortcuts to their own block type - #81624
Conversation
A variation shortcut applied to any block with a transform to the variation's block type, so a shortcut on a variation of a block with a wildcard transform — group, quote, details, columns — would have fired on every selected block. It now applies only where the selected block is already of that type. Reaching a variation from another block type is a transform, and is declared as one: a `type: 'block'` transform takes a `shortcuts` list rather than a single `shortcut`, and each entry may name the variation it produces. One transform can therefore carry a shortcut per variation without gaining an entry in the block switcher for each. The heading level shortcuts are declared in both places under one name: on the variations, for a heading, and on the transform from a paragraph. Registering a name more than once is expected as long as the declarations agree; only conflicting ones warn. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
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.
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. |
|
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 If 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. |
|
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.
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. |
|
Size Change: +68 B (0%) Total Size: 7.73 MB 📦 View Changed
|
7777e61
into
claude/block-shortcuts-review-followup
What?
Follow-up to #81588. Stacked on #81621 — review that one first, and this base retargets to
trunkonce it lands.A variation shortcut applied to any block with a transform to the variation's block type.
core/group,core/quote,core/detailsandcore/columnsall have wildcardfromtransforms, so a shortcut on one of their variations would have fired on every selected block.How?
Variation shortcuts now apply only where the selected block is already of that block type. Reaching a variation from another block type is a transform, and is declared as one: a
type: 'block'transform takes ashortcutslist rather than a singleshortcut, and each entry may name the variation it produces viavariationName.That last part is what keeps the block switcher untouched. Transforms are 1:1 with switcher entries, so six level-specific transforms would put six "Heading" rows in a paragraph's menu —
BlockTransformationItemrenders the block type's own title and never resolves the variation's. Hanging six shortcuts off one transform avoids that.The heading level shortcuts are declared in both places under the same
name: on theh1–h6variations for a selected heading, and on the transform from paragraph for everything else. The two can never both apply to one selection. Registering a name more than once is therefore expected, and only declarations that disagree warn.blockNamesis now always populated, so the unrestricted case is gone structurally rather than by an opt-out authors have to remember.No changelog entries: this refines the unreleased #81588 feature already described under
## Unreleased.Testing Instructions
Behaviour should be unchanged.
Testing Instructions for Keyboard
The feature is keyboard-only; the steps above cover it.
Use of AI Tools
Authored with Claude Code (Opus 5).