Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Global styles don't work in the Featured Product and Featured Category blocks #6988

Closed
Aljullu opened this issue Aug 25, 2022 · 2 comments · Fixed by #7000
Closed

Global styles don't work in the Featured Product and Featured Category blocks #6988

Aljullu opened this issue Aug 25, 2022 · 2 comments · Fixed by #7000
Assignees
Labels
block: featured category Issues related to the Featured Category block, block: featured product Issues related to the Featured Product block. focus: global styles Issues that involve styles/css/layout structure. type: bug The issue/PR concerns a confirmed bug. type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team.

Comments

@Aljullu
Copy link
Contributor

Aljullu commented Aug 25, 2022

To reproduce

  1. Install a block theme.
  2. Open Appearance > Site Editor.
  3. Add a Featured Product and a Featured Category block.
  4. Customize the global styles related to those blocks (click on the styles button on the top toolbar and then the Blocks section).

5. Notice the styles aren't applied.

Expected behavior

Global styles should work for those two blocks.

Additional context

According to this comment from @oandregal, the issue might be that we are not adding the correct class name to the blocks.

@Aljullu Aljullu added type: bug The issue/PR concerns a confirmed bug. block: featured category Issues related to the Featured Category block, block: featured product Issues related to the Featured Product block. focus: global styles Issues that involve styles/css/layout structure. type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team. labels Aug 25, 2022
@danielwrobert
Copy link
Contributor

danielwrobert commented Aug 26, 2022

Continuing to explore this but I'll share some initial findings after a first pass:

This comment from @oandregal (also linked above) states that these blocks use the wc-block-featured-product instead of the expected wp-block-woocommerce-featured-product class. What I'm seeing is that they use both classes - which is also consistent with the other blocks.

There are two key differences I've found with these two blocks and, for the sake of comparison, the Mini Cart block:

  1. The structure of the blocks - these Featured blocks apply the wc-block-featured-product class to a child element of the main block container and the wp-block-woocommerce-featured-product class to the main container. The Mini Cart block applies both classes to the main block container.
  2. There seems to be a missing CSS selector on these Featured blocks of .editor-styles-wrapper .wp-block-woocommerce-featured-product. Both of the classes are applied individually but they are not applied together, which is the selector that the Global Styles seem to use to apply the changes.

To give an example of the second point above, adding the following CSS block in Dev Tools will apply the expected Global Style visual adjustments in the editor:

.editor-styles-wrapper .wp-block-woocommerce-featured-product {
    background-color: var(--wp--preset--color--light-green-cyan);
    border-radius: 5px;
    border-color: #cf2e2e;
    border-width: 2px;
    border-style: solid;
    color: var(--wp--preset--color--vivid-purple);
}

I was viewing this with the following versions:

  • WP 6.0.1
  • WC 6.8.2 (also tested with 6.9.0 Beta 2)
  • WC Blocks 8.4.0-dev (also tested with 8.3.1)

In my findings, this only seems to be an issue in the Editor (Beta) part of the admin. When adding the block to a Post or Page, you can see the applied Global Styles, as expected. I'm also seeing the styles applied on the frontend, when saved. See the following screenshots for additional details.

Frontend view of block added via Editor (Beta) vs via Page:

Template (Home) Page
CleanShot 2022-08-25 at 22 11 41 CleanShot 2022-08-25 at 22 11 50

Admin/editor view of block added via Editor (Beta) vs via Page:

Template (Home) Page
CleanShot 2022-08-25 at 22 17 22 CleanShot 2022-08-25 at 22 05 34

Editor (Beta) Template with CSS (added via Dev Tools) vs Mini Cart Block (for comparison):

Featured Product (modified) Mini Cart (current state)
CleanShot 2022-08-25 at 22 05 03 CleanShot 2022-08-25 at 22 13 39

@danielwrobert
Copy link
Contributor

After further exploration, it seems that the culprit is the __experimentalDuotone property on the Supports attribute for these blocks.

After removing the property, everything seems to work as expected.

I'm not sure if it's the direction we want to go but I've made a PR (#7000) to remove this property from both of the impacted blocks.

Note that these were the only two blocks in the repository using this experimental property.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: featured category Issues related to the Featured Category block, block: featured product Issues related to the Featured Product block. focus: global styles Issues that involve styles/css/layout structure. type: bug The issue/PR concerns a confirmed bug. type: good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants