Skip to content

Edits to custom block style variations are lost #699

Open

Description

@onetrev

I believe the problem is Create Block Theme is trying to write the styles to your theme.json file and it's not supported yet, so what happens in nothing gets written, but Create Block Theme clears all db edits expecting the edits were saved to your theme.json file.

NOTE! If you are the Gutenberg plugin active, then it does work and your custom style variations are saved to theme.json.

  1. Use Twenty Twenty Four theme and WP 6.6.1.

  2. Created a Block Style Variation, whether created by JS, PHP, or Section Style, the same issue occurs. I used Section Style for this demo, since it's the fastest, so let's stick with that for recreating it.

  3. Here's the current style it set in my section style for a new custom block style for a button called "Fancy Button". It has black bg, white text.

Initial styles

  1. Now using the Site Editor "Styles" editor, make some changes. I made the bg orange.
    Change style of custom style variation

  2. Save changes with Create Block Theme, ensuring "Save Style Changes" is selected.
    Create Block Theme Save Styles

  3. Boom! All your styles are gone, the original block variation styles are back as they are not saved to your theme.json and the database changes are removed (the latter is supposed to happen since that's what Create Block Theme is meant to do).

Styles Gone

I've have also noted this issue in the Gutenberg repo, and have been working on it with @aaronrobertshaw.

Activity

  1. tHesTx commented on Feb 12, 2025

    @tHesTx

    Same thing happening with custom edits using a plugin (Nexter in my case). All edits are saved in a plus-css-nr.css file which is included in Edit site mode but not loaded in Visit site mode after Save Chenges to Theme , and styles are not copied anywhere.

  2. unscripted commented on May 14, 2025

    @unscripted
    Member

    I can confirm that I'm experiencing the same issue in WP 6.8.1.

  3. vegetable-bits commented on Sep 9, 2025

    @vegetable-bits

    @unscripted @onetrev I have various custom block variations and they working well. Maybe it's fixed already or because I'm using the latest Gutenberg Version?

    • Gutenberg plugin v21.5
    • WordPress 3.8.2
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions