WordPress / WordPress/create-block-theme

Edits to custom block style variations are lost

Open
#699 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Style variations
Dominant language
JavaScript
Stars
417
Forks
66
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Create Block Theme “Save Style Changes” flow and the theme.json handling described in the report, then compare it with Gutenberg issue 49602. Reproduce on WordPress 6.6.1 with Twenty Twenty Four using a custom button style variation and confirm that saving preserves the edited variation styles instead of restoring the originals.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, php
Domain
tooling, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.