Skip to content

Fix Accordion letter spacing lost after reopening the post - #3126

Merged
pirate-bot merged 1 commit into
developmentfrom
fix/accordion-letter-spacing-type
Oct 23, 2026
Merged

pirate-bot merged 1 commit into
developmentfrom
fix/accordion-letter-spacing-type

Conversation

@selul

@selul selul commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Requested by Marius · project thread

Closes #3124.

Summary

Before: the Accordion's Letter Spacing (Style → Typography) was saved, but when the post was reopened the control was empty, and the next save removed the spacing from the page.

After: the value is still there after reopening the post, and the front end keeps letter-spacing: 3px.

The letterSpacing attribute in accordion/group/block.json was declared as string, while the RangeControl, edit.js, the types file and class-accordion-css.php all treat it as a number. The block parser drops attribute values whose type does not match, so the saved "letterSpacing":3 was discarded on load.

How: the attribute now accepts ["number", "string"], the same declaration Advanced Heading uses for its typography attributes. Accepting string too keeps any value already stored as a string. No markup, deprecation or UI change.

Screenshots

None: no visual change.


Test instructions

  1. Insert an Accordion, select the parent block, Style → Typography, set Letter Spacing to 3, publish.
  2. Reload the editor and select the Accordion again: Letter Spacing shows 3.
  3. Change any other Accordion setting and update: the saved block still has "letterSpacing":3 and the front end has letter-spacing:3px on the item titles.

Verification

Check Result
New E2E Accordion Block › keeps letter spacing after the post is reopened, on the old string type FAIL (Expected 3, Received undefined), as intended
Same test with the fix PASS
accordion.spec.js + heading.spec.js (8 tests), local WordPress 7.1.3 / PHP 8.2 PASS
Front end of the saved post …accordion-item__title>*{letter-spacing:3px}
npm run test:unit PASS (356)
ESLint on the changed spec clean

Not proven: PHPUnit was not run (no PHP change); not checked on the WordPress 6.2 floor, though array attribute types have been supported since well before it.


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 by Claude Code

The letterSpacing attribute was declared as a string while the Letter
Spacing range control saves a number, so the editor discarded the saved
value on load and the next save removed it. Accept both types, as the
Advanced Heading block already does.

Closes #3124

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPwFxvA5VPq8sd4EzsNFFA
@selul selul self-assigned this Oct 20, 2026
@pirate-bot

Copy link
Copy Markdown
Contributor

Bundle Size Diff

Package Old Size New Size Diff
Animations 178.33 KB 178.33 KB 0 B (0.00%)
Blocks 1.65 MB 1.65 MB 11 B (0.00%)
CSS 7.83 KB 7.83 KB 0 B (0.00%)
Dashboard 172.49 KB 172.49 KB 0 B (0.00%)
Onboarding 68.14 KB 68.14 KB 0 B (0.00%)
Export Import 4.73 KB 4.73 KB 0 B (0.00%)
Pro 439.85 KB 439.85 KB 0 B (0.00%)

@pirate-bot

Copy link
Copy Markdown
Contributor

Plugin build for 864873b is ready 🛎️!

@pirate-bot

Copy link
Copy Markdown
Contributor

E2E Tests

Playwright Test Status: See serial and parallel matrix jobs

Performance Results serverResponse: {"q25":509.09,"q50":514.41,"q75":526.94,"cnt":10}, firstPaint: {"q25":1522.51,"q50":1666.76,"q75":2031.49,"cnt":10}, domContentLoaded: {"q25":4348.38,"q50":4397.95,"q75":4431.66,"cnt":10}, loaded: {"q25":4351.83,"q50":4401.97,"q75":4434.99,"cnt":10}, firstContentfulPaint: {"q25":2301.58,"q50":3232.45,"q75":3295.92,"cnt":10}, firstBlock: {"q25":20268.87,"q50":20336.2,"q75":20559.82,"cnt":10}, type: {"q25":32.45,"q50":35,"q75":39.25,"cnt":10}, typeWithoutInspector: {"q25":32.52,"q50":36.98,"q75":41,"cnt":10}, typeWithTopToolbar: {"q25":39.01,"q50":43.91,"q75":47.2,"cnt":10}, typeContainer: {"q25":18.92,"q50":20.46,"q75":20.89,"cnt":10}, focus: {"q25":166.21,"q50":176.89,"q75":196.73,"cnt":10}, inserterOpen: {"q25":50.48,"q50":56.66,"q75":60.66,"cnt":10}, inserterSearch: {"q25":35.06,"q50":36.3,"q75":37.3,"cnt":10}, inserterHover: {"q25":5.8,"q50":6.28,"q75":6.92,"cnt":20}, loadPatterns: {"q25":2192.82,"q50":2224.82,"q75":2307.74,"cnt":10}, listViewOpen: {"q25":289.01,"q50":311.02,"q75":319.55,"cnt":10}

@selul
selul requested a review from pirate-bot October 20, 2026 14:13

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

The fix keeps Accordion letter spacing after reload, and the new test fails without it.

Validation details
  • Files reviewed: 2/2 changed files.
  • The new E2E test passes at HEAD on WordPress 7.1.3 and PHP 8.3: cd /repo && export WP_BASE_URL=http://localhost:8080 WP_USERNAME=admin WP_PASSWORD=admin; set -o pipefail; timeout 280 n… printed keeps letter spacing after the post is reopened (run R10)
  • With the old string type, the same test fails on its assertion: ln -sfn /workspace/checks/R1/base /var/www/html/wp-content/plugins/otter-blocks && cd /workspace/checks/R1/base && expor… printed Received: undefined (run R13)
  • The saved post's front end has letter-spacing:3px on the item titles cd /repo && wp post list --post_type=post --post_status=publish --orderby=ID --order=DESC --fields=ID,post_name --format… (run R11, exit 0).
  • Consumers treat letterSpacing as a number, and Advanced Heading uses the same type list.
  • Question: the PR names a WordPress 6.2 floor, but readme.txt says 6.6. Array types work at 6.6.
Untested areas
  • The second save after another setting change was checked from source only.
  • Playwright ran with a local config without wp-env.

🤖 Automated review · run code-review-agent_6ad77714c2d949.22955786.


🤖 Review agent — review posted ✅ on 864873be · approved · 0 findings · 15 min

Run code-review-agent_6ad77714c2d949.22955786 · trail

@pirate-bot
pirate-bot merged commit 9af5741 into development Oct 23, 2026
15 checks passed
@pirate-bot
pirate-bot deleted the fix/accordion-letter-spacing-type branch October 23, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants