feat: show meaningful names for Atomic Wind blocks in List View#2861
Open
ineagu wants to merge 2 commits into
Open
feat: show meaningful names for Atomic Wind blocks in List View#2861ineagu wants to merge 2 commits into
ineagu wants to merge 2 commits into
Conversation
Pages built from atomic-wind blocks showed 'Box, Box, Box…' in the editor List View, and the box block's __experimentalLabel also suppressed core's native Rename feature (metadata.name was saved but never displayed). - add a shared label ladder for all five blocks: metadata.name (core Rename UI / generation-time name) first, then an attribute-derived fallback (semantic tagName for box, content for text, link text, image alt), then undefined so the block title and future variations still apply - declare the metadata attribute in block.json so custom names survive editor re-saves on WP 6.2-6.4 (core registers it globally only since 6.5; core skips already-defined keys, so no conflict on newer WP) - resolve the same names in the Atomic Wind class-editor tree and header, and fix the link preview reading the wrong attribute (content instead of text) Labels live only in comment-delimiter JSON / display code, so existing content benefits retroactively with no markup changes and no block validation risk. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Bundle Size Diff
|
Contributor
|
Plugin build for c7bb373 is ready 🛎️!
|
Contributor
E2E TestsPlaywright Test Status: See serial and parallel matrix jobs Performance ResultsserverResponse: {"q25":404.8,"q50":425.95,"q75":445.9,"cnt":10}, firstPaint: {"q25":553.6,"q50":669.4,"q75":729.4,"cnt":10}, domContentLoaded: {"q25":3302.3,"q50":3335.7,"q75":3401.4,"cnt":10}, loaded: {"q25":3303,"q50":3336.4,"q75":3401.9,"cnt":10}, firstContentfulPaint: {"q25":9150.9,"q50":9215.9,"q75":9295.3,"cnt":10}, firstBlock: {"q25":13964,"q50":14119,"q75":14185.7,"cnt":10}, type: {"q25":22.82,"q50":24.55,"q75":25.75,"cnt":10}, typeWithoutInspector: {"q25":21.43,"q50":22.04,"q75":23.55,"cnt":10}, typeWithTopToolbar: {"q25":29.8,"q50":31.74,"q75":33.01,"cnt":10}, typeContainer: {"q25":14.21,"q50":14.92,"q75":16.61,"cnt":10}, focus: {"q25":113.02,"q50":115.43,"q75":117.79,"cnt":10}, inserterOpen: {"q25":38.36,"q50":38.79,"q75":39.75,"cnt":10}, inserterSearch: {"q25":13.12,"q50":13.48,"q75":13.73,"cnt":10}, inserterHover: {"q25":5.4,"q50":5.51,"q75":5.68,"cnt":20}, loadPatterns: {"q25":1521.07,"q50":1548.91,"q75":1660.07,"cnt":10}, listViewOpen: {"q25":213.43,"q50":217.19,"q75":219.54,"cnt":10} |
Review follow-ups: resolve tag labels at call time (picks up locale data registered after module init and avoids Object.prototype lookups on crafted tagName values), return raw content/text values from the label callbacks so core converts RichTextData and decodes entities exactly once, and only decode the plain-string branch in the class editor preview. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pages built with Atomic Wind show Box, Box, Box, Box… in the editor List View — every wrapper is the generic
atomic-wind/boxblock, so users can't tell their hero from their testimonials.On top of that, the box block's existing
__experimentalLabel(Box <tagName>) silently broke core's native Rename feature: core only displaysattributes.metadata.namethrough an auto-injected label callback, and it bails when a block defines its own. So renaming a Box via the List View Rename modal saved the name but never displayed it.Solution: a shared label ladder (
src/atomic-wind/blocks/labels.js) registered as__experimentalLabelon all five blocks, resolving in List View/breadcrumb contexts:attributes.metadata.name— the custom name from core's Rename UI, or set at content-generation time (<!-- wp:atomic-wind/box {"metadata":{"name":"Testimonial Section"}} -->)section→ Section,nav→ Navigation, …), text content for text, link text for link, alt for imageundefined— falls through to the block title, keeping future block-variation titles workingThis is the same precedence GenerateBlocks 2.x ships for its generic Element block, and what core blocks (heading, paragraph, image) do. Content values are returned raw (string or RichTextData) so core converts and decodes them exactly once.
Also:
"metadata": { "type": "object" }in the fiveblock.jsonfiles — defensive for older WP: the client-side editor already preserves the attribute everywhere, and core's server-side global registration (WP 6.5+) skips already-defined keys, so this is conflict-freeattributes.contentbut the link block stores its label intext(it was always empty)Why it's safe: names live only in the block-comment JSON and display-only code paths —
save()output is untouched, so no block validation/deprecation risk, and existing pages get readable names retroactively on update.div/spanboxes intentionally keep showing Box (no semantic signal to derive from). The Rename UI is core's own (WP 6.5+, on by default); this PR just stops suppressing it.Follow-up (separate concern): the atomic-wind
block.jsonfiles declare"textdomain": "atomic-wind"while all JS strings (pre-existing and new) useotter-blocks, so none of these strings currently get translations. Worth aligning repo-wide in its own PR.Test instructions
tagName: sectioncontaining text/images), open the List View.save()).npm run test:unit—src/atomic-wind/blocks/test/labels.test.jscovers the ladder precedence, contexts, and edge cases.Checklist before the final review
🤖 Generated with Claude Code