Skip to content

wp7 Paragraph block migration incorrectly copies color classes into className and corrupts textColor when align attribute is present #78719

Closed

Description

@bigdigital

Description

When opening a post containing a paragraph block with both align and textColor attributes (saved in the pre-WP7 format), the block migration introduced in #73111
#73578 incorrectly copies color classes into the className attribute and replaces the correct textColor value with base.

Why this is a critical bug
Once corrupted, the block is broken in two ways:

Color cannot be changed , has-accent-1-color is now hardcoded in className. Even if the user picks a new color in the editor, the old class stays stuck in the

tag alongside the new one, because className classes are never replaced only added to.

Step-by-step reproduction instructions

1 . Create a post, switch to Code editor and paste following code. (here accent-1 color is default color from 2025 theme )

<!-- wp:paragraph {"align":"left","textColor":"accent-1"} -->
<p class="has-text-align-left has-accent-1-color has-text-color">test</p>
<!-- /wp:paragraph -->
  1. Switch to Visual editor, open block settings and change color to any custom color.
  2. Observe the text color not changing.

Expected behavior

The align attribute is moved to style.typography.textAlign, textColor is preserved, no className is added:
<!-- wp:paragraph {"style":{"typography":{"textAlign":"left"}},"textColor":"accent-1"} -->
<p class="has-text-align-left has-accent-1-color has-text-color">test</p>

Actual behavior
Color classes are leaked into block className also they are left in P itself :

<!-- wp:paragraph {"className":"has-accent-1-color has-text-color","style":{"typography":{"textAlign":"left"},"color":{"text":"#14f24b"}}} -->
<p class="has-text-align-left has-accent-1-color has-text-color" style="color:#14f24b">test</p>
<!-- /wp:paragraph -->

Screenshots, screen recording, code snippet

Image

Environment info

WordPress 7.0
2025 theme

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Activity

  1. added
    [Type] Bug
    on May 27, 2026
  2. added
    [Block] Paragraph
    on May 27, 2026
  3. Mamaduka commented on May 27, 2026

    @Mamaduka
    Member

    @t-hamano, this is worth fixing and including in the next minor.

  4. added
    [Status] In Progress
    on May 27, 2026
  5. bigdigital commented on May 27, 2026

    @bigdigital
    Author

    Additional edge cases found on our production
    After investigating affected sites we found two further broken states that occur when users interact with already-corrupted blocks in the editor.
    Edge case 1: Double color class after changing text color
    When a user opens a corrupted block and picks a new color in the editor, the old leaked class stays stuck in className while the new color class is added by the block renderer. Result: two conflicting color classes on the P tag simultaneously.

    <!-- wp:paragraph {"className":"has-accent-1-color has-text-color","style":{"typography":{"textAlign":"left"}},"textColor":"accent-3"} -->
    <p class="has-text-align-left has-accent-1-color has-text-color has-accent-3-color">test</p>
    <!-- /wp:paragraph -->
    

    Here has-accent-1-color is the leaked class from the bad migration, has-accent-3-color is the newly selected color. Both appear on the P simultaneously. The block renders with unpredictable color depending on CSS specificity. The user cannot fix this through the editor UI because className is never cleaned up by the color picker.

    Edge case 2: Stuck color class after clearing text color
    When a user clears the text color on an already-corrupted block, textColor is removed from attrs but the leaked className remains. The block now has no textColor attribute but still renders with the old color visually, the user cannot remove it.

    <!-- wp:paragraph {"className":"has-accent-1-color has-text-color","style":{"typography":{"textAlign":"left"}}} -->
    <p class="has-text-align-left has-accent-1-color has-text-color">test</p>
    <!-- /wp:paragraph -->
    

    The color appears cleared in the editor UI (no color selected in the panel) but the P still renders with has-accent-1-color applied. This is a silent visual discrepancy with no way to resolve it without manually editing the block HTML.

  6. moved this to 📋 Iteration/Tracking Issues in WordPress 7.0 Editor Taskson May 28, 2026
  7. moved this from 📋 Iteration/Tracking Issues to 🏗️ In Progress in WordPress 7.0 Editor Taskson May 28, 2026
  8. moved this from 🏗️ In Progress to ✅ Done in WordPress 7.0 Editor Taskson May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] Paragraph[Status] In Progress[Type] Bug

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions