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: Ponyfill css overrides block-level global styles for Button block #4435

Closed
jeyip opened this issue Aug 17, 2021 · 10 comments
Closed
Labels
[Theme] Blockbase [Type] Bug Something isn't working

Comments

@jeyip
Copy link
Contributor

jeyip commented Aug 17, 2021

Description

I'm seeing an issue with block-level global styling being overridden in the dotcom site editor and frontend (atomic + simple sites), and it looks like it has to do with the ponyfill.css file in blockbase. When I remove ponyfill.css, per block global styles work as expected.

List of affected blocks

  1. Button (text color and background color)
  2. Cover (text color and background color) Not caused by blockbase
  3. Site Title (text color and background color) Not caused by blockbase
  4. Cover and Group blocks (right/left padding)

Steps to replicate

  1. On a simple or atomic site, activate a block theme that depends on blockbase
  2. Activate the site editor
  3. Navigate to the site editor
  4. Insert a button block onto the page and add text content
  5. Open the global styles sidebar, and select the "By Block Type" menu tab
  6. Unfold the Button block-level global styles panel and select different color options
  7. Confirm that the color options do not change according to user customizations

Button Block

2021-08-16 13 58 39

Result

User customized global styles (like background color) weren't applied to the block

Expected

The block styles would change according to user customizations

Notes

  • Slack Discussion: p1629226103080900-slack-C029FM1EH
@jeyip jeyip added [Type] Bug Something isn't working [Theme] Blockbase labels Aug 17, 2021
@jeyip jeyip changed the title Blockbase: Ponyfill css overrides global styles block-level styling Blockbase: Ponyfill css overrides block-level global styles Aug 17, 2021
@pbking
Copy link
Contributor

pbking commented Aug 17, 2021

The button portion of the related ponyfill is here. That relates to the video shown but it's not the only place where this is happening.

This is happening because many of Blockbase's selectors have a higher specificity than the styles generated by Global Styles. This is especially obvious with the button which has a rich ponyfill system including hover states (which are going to be particularly problematic to address in this situation).

@jffng
Copy link
Contributor

jffng commented Aug 18, 2021

I believe this affects the editor and the view slightly differently.

In the case of the button (ignoring the hover states issue), we could theoretically solve the issue by remove the wrapping selector .wp-block-button and the global styles customizations win because they load later in the cascade. @mikachan and I tested this and it works in the editor.

However, in the view, the theme CSS is loaded after the global styles CSS, so the theme CSS is still winning. This is a mismatch between editor and view, and also not the preferred order. We opened an issue above to see if we can fix this upstream.

Front-end source:

Screen Shot 2021-08-18 at 10 50 54 AM

@mikachan
Copy link
Member

I had a quick look at this in Gutenberg and then in Blockbase. I couldn't change the order of global-styles-inline-css in Gutenberg other than moving it above wp-block-library-css. I did this in this file by changing the priority like so:

add_action( 'wp_enqueue_scripts', 'gutenberg_experimental_global_styles_enqueue_assets', 999 );

I did manage to force the order via Blockbase, by again changing the priority of the styles in functions.php:

add_action( 'wp_enqueue_scripts', 'blockbase_scripts', 0 );

Which did this:

Screenshot 2021-08-18 at 16 56 19

But I guess this isn't ideal as every theme would need to cater for this.

Thought I'd report back in case this helps in any way, or makes it quicker for someone to work some Gutenberg magic.

@creativecoder
Copy link
Contributor

Thanks for investigating @mikachan !

It looks like WP 5.8 is registering the 'global-styles' stylesheet as well, which is taking precedence over Gutenberg's enqueue calls. But Gutenberg should be able to unregister and reregister the asset to work around this. I'll spin up a Gutenberg PR.

@creativecoder
Copy link
Contributor

Potential fix for this at WordPress/gutenberg#34147. As pointed out earlier, Blockbase styles will still need to be updated to have a css selector specificity equal or below Global Styles css.

@jeyip
Copy link
Contributor Author

jeyip commented Aug 19, 2021

It looks like issues with global styles and the cover block can be attributed to specificity problems in core Gutenberg, and not from themes. WordPress/gutenberg#34150. I'll be taking a closer look tomorrow.

@jeyip
Copy link
Contributor Author

jeyip commented Aug 20, 2021

Issues with global styles and the site title block are caused by CSS specificity conflicts with seedlet-blocks, not blockbase.

  • Block level global styles are being applied to the site title through .wp-block-site-title a
  • The Seedlet blocks theme has a competing declaration via .is-root-container a:not(.wp-block-button__link):not([download])

/**
* Links in Content
*/
.is-root-container a:not(.wp-block-button__link):not([download]),
.wp-block-post-content a:not(.wp-block-button__link):not([download]) {
color: var(--wp--custom--color--primary);
text-decoration-color: var(--wp--style--color--link);
text-decoration-thickness: 1px;
text-underline-offset: 0.2em;
}

I drafted a separate issue and a separate PR to address this.

@jeyip jeyip changed the title Blockbase: Ponyfill css overrides block-level global styles Blockbase: Ponyfill css overrides block-level global styles for Button block Aug 20, 2021
@creativecoder
Copy link
Contributor

I found an additional conflict with Blockbase and block specific Global Styles, right/left padding on the Group and Cover blocks are being overridden by Blockbase.

(Global Styles css on the bottom, Blockbase css on the top in both images)

Cover block

Screen Shot 2021-08-21 at 06 18 47

Group block

Screen Shot 2021-08-21 at 06 19 18

@pbking
Copy link
Contributor

pbking commented Aug 23, 2021

Thanks @creativecoder. That (slightly separate) issue is being dealt with in either this PR or maybe this one.

@pbking
Copy link
Contributor

pbking commented Aug 23, 2021

I think that everything Button-related that CAN be solved has been via #4439 (with the known exceptions of hover state and outline variation).

Blockbase alignment issues are being looked at this week in #4456

Going to close this one as complete. Please reopen if anything not tracked elsewhere continues to be an issue.

@pbking pbking closed this as completed Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Theme] Blockbase [Type] Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants