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

Customizer custom colors preview overriden by style.css #111

Closed
claudiulodro opened this issue Jul 18, 2019 · 7 comments
Closed

Customizer custom colors preview overriden by style.css #111

claudiulodro opened this issue Jul 18, 2019 · 7 comments
Labels
[Type] Bug Incorrect behavior or functionality

Comments

@claudiulodro
Copy link
Contributor

Describe the bug
In the Customizer, when I have a custom color selected, I get a flash of the color when the page is first loaded for .5 seconds, and then it all gets replaced with the default Newspack color. Selecting a custom color doesn't show the color in the Customizer, and it's always mighty blue all the time. On the site frontend, the custom color works great.

In the inspector, if I examine e.g. a Search button I see the default color is active:
style.css

.button, button, input[type="button"], input[type="reset"], input[type="submit"] {
    background: #2A7DE1;
    ...
}

At a lower priority (striked through in the inspector), my custom color is inactive:
http://{site}/?customize_changeset_uuid={uuid}&customize_theme=newspack-theme&customize_messenger_channel=preview-0

.main-navigation .sub-menu, .sticky-post, .entry .entry-content .wp-block-button .wp-block-button__link:not(.has-background), .entry .button, button, input[type="button"], input[type="reset"], input[type="submit"], .entry .entry-content > .has-primary-background-color, .entry .entry-content > *[class^="wp-block-"].has-primary-background-color, .entry .entry-content > *[class^="wp-block-"] .has-primary-background-color, .entry .entry-content > *[class^="wp-block-"].is-style-solid-color, .entry .entry-content > *[class^="wp-block-"].is-style-solid-color.has-primary-background-color, .entry .entry-content .wp-block-file .wp-block-file__button {
    background-color: #eab700; /* My custom color */
}

Potentially related to #52? (The issue happens without a style pack active in my testing, though)

To Reproduce
Steps to reproduce the behavior:

  1. Go to Customizer
  2. Set a custom color. Observe it doesn't preview.
  3. Save. Refresh the page. Observe custom color is overriden by style.css.

Expected behavior
I expected the custom color preview to preview normally.

@claudiulodro claudiulodro added the [Type] Bug Incorrect behavior or functionality label Jul 18, 2019
@laurelfulford
Copy link
Contributor

This might be related to #52 -- the issue hangs around even after you've switched back to the default style pack, as long as it's been changed at some point in the past -- it's due to my clunky code for the Customizer.

@claudiulodro do you remember if you switched the style pack at any point on this test site?

@claudiulodro
Copy link
Contributor Author

Not sure. I should be getting my new computer today, so I'll give it a test on a clean slate and see.

@laurelfulford
Copy link
Contributor

Thanks! (And yay new computer!! 🎉 )

@claudiulodro
Copy link
Contributor Author

Just tested on the cleanest of new sites, and the issue still happens. It's not because I had a style pack and then removed it.

@laurelfulford
Copy link
Contributor

Thanks for double-checking!

Dang, this could be a bigger issue than I thought.

@claudiulodro
Copy link
Contributor Author

Did a little more digging into this, and it seems to def. be related to the style packs. If I remove add_action( 'customize_preview_init', array( $this, 'customize_preview' ) ); from Newspack_Style_Packs_Core the customizer colors work great.

The underlying issue to me looks like style.css is getting enqueued twice:

  • Once normally
  • Once by the style pack JS

The second enqueue (the one by style pack) overrides the customizer styles, since the styles all have the same specificity but the style pack loads style.css after the customizer styles have been applied.

Closing this issue since it seems to be the same as #52. Hope this info helps! :)

@laurelfulford
Copy link
Contributor

Yes -- thanks @claudiulodro!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug Incorrect behavior or functionality
Projects
None yet
Development

No branches or pull requests

2 participants