Skip to content

feat: show meaningful names for Atomic Wind blocks in List View#2861

Open
ineagu wants to merge 2 commits into
developmentfrom
feat/atomic-wind-list-view-labels
Open

feat: show meaningful names for Atomic Wind blocks in List View#2861
ineagu wants to merge 2 commits into
developmentfrom
feat/atomic-wind-list-view-labels

Conversation

@ineagu

@ineagu ineagu commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Pages built with Atomic Wind show Box, Box, Box, Box… in the editor List View — every wrapper is the generic atomic-wind/box block, 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 displays attributes.metadata.name through 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 __experimentalLabel on all five blocks, resolving in List View/breadcrumb contexts:

  1. 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"}} -->)
  2. attribute-derived fallback — semantic tag label for box (sectionSection, navNavigation, …), text content for text, link text for link, alt for image
  3. undefined — falls through to the block title, keeping future block-variation titles working

This 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:

  • declares "metadata": { "type": "object" } in the five block.json files — 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-free
  • the Atomic Wind class-editor panel tree/header now resolves the same names instead of always showing the block title
  • fixes a latent panel bug: the link preview read attributes.content but the link block stores its label in text (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/span boxes 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.json files declare "textdomain": "atomic-wind" while all JS strings (pre-existing and new) use otter-blocks, so none of these strings currently get translations. Worth aligning repo-wide in its own PR.


Test instructions

  1. Create a page with Atomic Wind blocks (e.g. a Box with tagName: section containing text/images), open the List View.
  2. Boxes with semantic tags show Section / Header / Navigation etc.; text blocks show their content; links show their label; images show their alt text.
  3. Right-click a block in List View → Rename → the custom name now displays in List View and the breadcrumb (previously it saved but never showed).
  4. Open the Atomic Wind floating panel (class editor): the tree and header show the same names, and link blocks show their text preview (previously empty).
  5. Re-save the page and reload: names persist; front-end markup is byte-identical (labels never touch save()).
  6. npm run test:unitsrc/atomic-wind/blocks/test/labels.test.js covers the ladder precedence, contexts, and edge cases.

Checklist before the final review

  • Included E2E or unit tests for the changes in this PR.
  • Visual elements are not affected by independent changes.
  • It is at least compatible with the minimum WordPress version.
  • It loads additional script in frontend only if it is required.
  • Does not impact the Core Web Vitals.
  • In case of deprecation, old blocks are safely migrated.
  • It is usable in Widgets and FSE.
  • Copy/Paste is working if the attributes are modified.
  • PR is following the best practices

🤖 Generated with Claude Code

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>
@pirate-bot

Copy link
Copy Markdown
Contributor

Bundle Size Diff

Package Old Size New Size Diff
Animations 178.24 KB 178.24 KB 0 B (0.00%)
Blocks 1.47 MB 1.47 MB 0 B (0.00%)
CSS 7.87 KB 7.87 KB 0 B (0.00%)
Dashboard 108.48 KB 108.48 KB 0 B (0.00%)
Onboarding 68.14 KB 68.14 KB 0 B (0.00%)
Export Import 4.7 KB 4.7 KB 0 B (0.00%)
Pro 299.31 KB 299.31 KB 0 B (0.00%)

@pirate-bot

pirate-bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Plugin build for c7bb373 is ready 🛎️!

@pirate-bot

pirate-bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

E2E Tests

Playwright Test Status: See serial and parallel matrix jobs

Performance Results serverResponse: {"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>
@pirate-bot pirate-bot added the pr-checklist-complete The Pull Request checklist is complete. (automatic label) label Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-checklist-complete The Pull Request checklist is complete. (automatic label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants