Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blockbase: Fix previewing post editor colors from style variations in child themes #8575

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

adamwoodnz
Copy link

@adamwoodnz adamwoodnz commented Jan 14, 2025

Fixes #6963

Changes proposed in this Pull Request:

This PR removes the !important from the fallback color rules in the Blockbase stylesheet. The actual colors are defined in theme.json and generated in global styles, and these !important fallbacks cause problems in child themes with style variations loaded, when previewing colors in the post editor. The issue was raised referencing the Attar theme, but it is reproducible with other Blockbase child themes, like Ames.

Please note that these rules do not cause the same issues when the Blockbase theme itself is activated, or in the site editor, or on the frontend.

With a child theme like Attar activated and a style variation selected, the Blockbase theme styles are inlined in the post editor document after the style variation styles, overriding them and causing the color to be set to the Blockbase theme default custom colors:

Screenshot 2025-01-14 at 7 03 15 PM

Lowering the specificity of these rules allows the correct color presets generated from the style variation to be used, as expected.

An alternative fix could be to adjust the loading order, so that the Blockbase stylesheet is inlined before the global styles. I'm not aware of this happening with other non Blockbase themes however.

Screenshots (Theme: Attar, Style variation: Charcoal)

Before After
Text Screenshot 2025-01-14 at 6 46 08 PM Screenshot 2025-01-15 at 2 50 03 PM
Button Screenshot 2025-01-14 at 6 45 52 PM Screenshot 2025-01-15 at 2 47 57 PM

Testing

We need to test both the Blockbase theme and child themes.

  1. Activate the Attar theme
  2. Under Appearance -> Editor -> Styles, select a style variation and save
  3. Edit a post, changing the color of elements using colors from the color palette (should be the colors from the style variation)
  4. Observe that the colors are applied in the post editor preview
  5. Save and check that the post on the frontend matches the post editor preview
  6. Return to the admin and use the site editor to edit a page or template, changing colors
  7. Observe that the colors are applied in the site editor preview
  8. Save and check that the page on the frontend matches the site editor preview
  9. Activate the Blockbase theme and repeat steps 2 - 8

Further regression testing:

  • Activate other child themes and repeat steps 2 - 8
  • Repeat steps 3 - 8 with Blockbase or a child theme, and no style variation selected

Copy link
Contributor

Preview changes

I've detected changes to the following themes in this PR: Blockbase.
You can preview these changes by following the links below:

I will update this comment with the latest preview links as you push more changes to this PR.

Note

The preview sites are created using WordPress Playground. You can add content, edit settings, and test the themes as you would on a real site, but please note that changes are not saved between sessions.

@adamwoodnz adamwoodnz changed the title Blockbase: Fix issues with style variations in post editor Blockbase: Fix issues in child themes with style variations in post editor Jan 14, 2025
@adamwoodnz adamwoodnz changed the title Blockbase: Fix issues in child themes with style variations in post editor Blockbase: Fix previewing post editor colors from style variations in child themes Jan 14, 2025
@adamwoodnz adamwoodnz force-pushed the fix/6963-blockbase-child-style-variations branch from 2987277 to 36e25fc Compare January 15, 2025 01:03
@adamwoodnz adamwoodnz force-pushed the fix/6963-blockbase-child-style-variations branch from 36e25fc to 46a9a12 Compare January 15, 2025 02:16
@adamwoodnz adamwoodnz marked this pull request as ready for review January 15, 2025 02:16
@adamwoodnz adamwoodnz added [Theme] Blockbase [Themes] Attar Customer Report Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report". [Type] Bug Something isn't working [Status] Needs Testing Block Rendering labels Jan 15, 2025
@adamwoodnz adamwoodnz self-assigned this Jan 15, 2025
Copy link
Contributor

Theme-Check results

blockbase: No changes required ✅.

💡 RECOMMENDED (1)
  • Possible variable $header_pattern found in translation function in inc/block-patterns.php. Translation function calls must not contain PHP variables, use placeholders instead. See Internationalization Guidelines (Opens in a new window). Line 39: $header_patterns = array(Line 48: foreach ( $header_patterns as $header_pattern ) {Line 50: 'blockbase/header-' . $header_pattern,Line 52: 'title' => __( 'Blockbase Header (' . $header_pattern . ')', 'blockbase' ),Line 55: 'content' => file_get_contents (get_theme_file_path( '/parts/header-' . $header_pattern . '.html' )),
⚠️ WARNING (4)
  • screenshot.png is 555.6 KB in size. Large file sizes have a negative impact on website performance and loading time. Compress images before using them.
  • Found a translation function that has an incorrect number of arguments in the file inc/block-patterns.php. Function __, with the arguments 'Blockbase Header (', ), 'blockbase'. Line 52: 'title' => __( 'Blockbase Header (' . $header_pattern . ')', 'blockbase' ),
  • Found a translation function that is missing a text-domain in the file inc/customizer/wp-customize-fonts.php. Function __, with the arguments 'https://wordpress.com/support/custom-fonts/'. Line 13: __( 'https://wordpress.com/support/custom-fonts/' )
  • More than one text-domain is being used in this theme. This means the theme will not be compatible with WordPress.org language packs. The domains found are blockbase, ).

Copy link
Member

@mikachan mikachan left a comment

Choose a reason for hiding this comment

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

These changes fix the issue described in #6963 for me, and I agree with this reasoning:

Lowering the specificity of these rules allows the correct color presets generated from the style variation to be used, as expected.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Block Rendering Customer Report Issues or PRs that were reported via Happiness. aka "Happiness Request", or "User Report". [Status] Needs Testing [Theme] Blockbase [Themes] Attar [Type] Bug Something isn't working
Projects
None yet
2 participants