-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix: setting a preset color on pullquote default style makes the block invalid #18194
Fix: setting a preset color on pullquote default style makes the block invalid #18194
Conversation
c642917
to
65af668
Compare
Hi @jorgefilipecosta, thanks for dealing with these issues. It seems to be pretty reasonable to make a new iteration to this implementation but wondering since we are going to make a refactoring whether it worths to take a look at the |
Hi @retrofox, this PR will be cherry-picked into WordPress 5.3, so we should try to keep it as simple as possible. The useColors hook is experimental and not part of WordPress 5.3, so I think we can not use it. |
65af668
to
6775d92
Compare
I haven't taken a look at the code yet but did to its functionality. Questions: front-end env Although the colors are being applied to the Maybe we could add |
Hi @retrofox,
In this PR, we don't apply background colors by inline styles when they are defined through a color palette. We apply border colors with inline styles even if they are defined through a palette, and that was already the case. We do it because themes don't provide classes with border styles. For backgrounds, we use classes because themes provide background classes. Although the colors are being applied to the wp-block-pullquote element, there is a stronger rule that overrides what the PullQuote block applies, at least with my testing theme. element ? |
Got confused, I wanted to say to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems its a collision with themes I guess we can try to improve the styles. But doing that, we may cause problems in other themes that currently work well. And this problem already happened on previous WordPress releases. Given that we are already late on the RC stage, I would prefer to try in a follow-up PR, not part of the release, and on this PR focus on the immediate issue.
Sorry, what I'm trying to say is that, if the user sets explicitly the border-color of the pull-quote, should not we try to apply these styles in the front-end without making collisions?
I've set the border color and the text color in the quote:
I expect to see these changes in the front-end. We're facing a similar case in the <NavigationMenu />, where the user is able to set up text and background-color of the menu.
The styles are being applied through either with CSS classes as well as inline styles, but also applying other rules if it's needed, conditionally to the has-text-color
or/and has-background-color
class/es.
Anyway, I've tested the PR and it works as (almost ;-)) expected. It's up to you pay attention to these comments. Maybe it worths to know the opinion of other folks. And finally, we can keep improving it later.
How do currently invalid blocks work with this change? I mean what will happen when they open the editor, will the pull quote be updated, will the color be discarded? |
ceff8d2
to
42a1088
Compare
Hi @retrofox, @youknowriad, thank you for your questions/insights.
Hi @youknowriad, I found a solution to keep the named colors and migrate them to custom colors, so for the user, these changes should be transparent. The block should continue to be exactly as before.
Hi @retrofox, this pull request is supposed to solve that bug. Are you able to replicate the problem in this branch, or you verified this PR solved the bug?
The problem is that what we make to avoid collisions in one theme can have collisions in another theme. I think we can try to improve the styles to minimize common collisions in existing themes. But, I think it is not something we should try in this stage of the release. |
Fair enough. |
42a1088
to
7f6eccf
Compare
Merging this PR as it is a priority and the more testing it gets, the better. If anyone has any other suggestions, I will happily open a follow-up PR. |
…rnmobile/gb-mobile-872-JSApplicationIllegalArgumentException-in-RCTAztecView * 'master' of https://github.com/WordPress/gutenberg: (56 commits) Update: Default gradients. (#18214) Fix: setting a preset color on pullquote default style makes the block invalid (#18194) Fix default featured image size (#15844) Fix postmeta radio regression. (#18183) Components: Switch screen-reader-text to VisuallyHidden (#18165) [rnmobile] Release 1.16.0 to master (#18261) Template Loader: Add theme block template resolution. (#18247) Add a README file for storybook directory (#18245) Add editor-gradient-presets to get_theme_support (#17841) Add "Image Title Attribute" as an editable attribute on the image block (#11070) enables horizontal movers in social blocks (#18234) [RNMobile] Add mobile Spacer component (#17896) Add experimental `ResponsiveBlockControl` component (#16790) Fix mover for floats. (#18230) Rename Component to WPComponent in docstring (#18226) Colors Selector: replace `Aa` text by SVG icon (#18222) Removed gif from README (#18200) makes the submenu items stacked vertically (#18221) Add block navigator to sidebar panel for nav block (#18202) Fix: consecutive updates may trigger a blocks reset (#18219) ...
…k invalid (#18194) * Fix: setting a preset color on pullquote default style makes the block invalid. * Updated deprecation to keep the colors
…k invalid (#18194) * Fix: setting a preset color on pullquote default style makes the block invalid. * Updated deprecation to keep the colors
The list of included fixes is: WordPress/gutenberg#18183 WordPress/gutenberg#18194 WordPress/gutenberg#18230 WordPress/gutenberg#18275 WordPress/gutenberg#18287 Updated packages: - @wordpress/block-editor@3.2.4 - @wordpress/block-library@2.9.5 - @wordpress/edit-post@3.8.5 - @wordpress/editor@9.7.5 - @wordpress/format-library@1.9.4 Props @aduth, @mcsf, @youknowriad, @johnbillion. Fixes #48502. git-svn-id: https://develop.svn.wordpress.org/trunk@46656 602fd350-edb4-49c9-b593-d223f7449a82
The list of included fixes is: WordPress/gutenberg#18183 WordPress/gutenberg#18194 WordPress/gutenberg#18230 WordPress/gutenberg#18275 WordPress/gutenberg#18287 Updated packages: - @wordpress/block-editor@3.2.4 - @wordpress/block-library@2.9.5 - @wordpress/edit-post@3.8.5 - @wordpress/editor@9.7.5 - @wordpress/format-library@1.9.4 Props @aduth, @mcsf, @youknowriad, @johnbillion. Fixes #48502. git-svn-id: https://develop.svn.wordpress.org/trunk@46656 602fd350-edb4-49c9-b593-d223f7449a82
The list of included fixes is: WordPress/gutenberg#18183 WordPress/gutenberg#18194 WordPress/gutenberg#18230 WordPress/gutenberg#18275 WordPress/gutenberg#18287 Updated packages: - @wordpress/block-editor@3.2.4 - @wordpress/block-library@2.9.5 - @wordpress/edit-post@3.8.5 - @wordpress/editor@9.7.5 - @wordpress/format-library@1.9.4 Props @aduth, @mcsf, @youknowriad, @johnbillion. Fixes #48502. Built from https://develop.svn.wordpress.org/trunk@46656 git-svn-id: http://core.svn.wordpress.org/trunk@46456 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The list of included fixes is: WordPress/gutenberg#18183 WordPress/gutenberg#18194 WordPress/gutenberg#18230 WordPress/gutenberg#18275 WordPress/gutenberg#18287 Updated packages: - @wordpress/block-editor@3.2.4 - @wordpress/block-library@2.9.5 - @wordpress/edit-post@3.8.5 - @wordpress/editor@9.7.5 - @wordpress/format-library@1.9.4 Props @aduth, @mcsf, @youknowriad, @johnbillion. Fixes #48502. Built from https://develop.svn.wordpress.org/trunk@46656 git-svn-id: https://core.svn.wordpress.org/trunk@46456 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The list of included fixes is: WordPress/gutenberg#18183 WordPress/gutenberg#18194 WordPress/gutenberg#18230 WordPress/gutenberg#18275 WordPress/gutenberg#18287 Updated packages: - @wordpress/block-editor@3.2.4 - @wordpress/block-library@2.9.5 - @wordpress/edit-post@3.8.5 - @wordpress/editor@9.7.5 - @wordpress/format-library@1.9.4 Props @aduth, @mcsf, @youknowriad, @johnbillion. Fixes #48502. Built from https://develop.svn.wordpress.org/trunk@46656
The list of included fixes is: WordPress/gutenberg#18183 WordPress/gutenberg#18194 WordPress/gutenberg#18230 WordPress/gutenberg#18275 WordPress/gutenberg#18287 Updated packages: - @wordpress/block-editor@3.2.4 - @wordpress/block-library@2.9.5 - @wordpress/edit-post@3.8.5 - @wordpress/editor@9.7.5 - @wordpress/format-library@1.9.4 Props @aduth, @mcsf, @youknowriad, @johnbillion. Fixes #48502. git-svn-id: http://develop.svn.wordpress.org/trunk@46656 602fd350-edb4-49c9-b593-d223f7449a82
Fixes: #16429
The color mechanism on pull quotes is complex.
On the default style, the main color sets a border while on the solid color style, it sets a background.
The color mechanism uses a class for preset colors and does not set the color values on the attribute, but for borders, we don't have classes.
Previously we used the color mechanism normally for both styles and on the save function given that for presets colors, we don't have the color value as an attribute we queried the block-editor store settings to retrieve the color value and used the value in a border style.
The implementation is not correct, and it was a wrong decision because the save function becomes impure. Although not correct, It was working without block validation issues in the current WordPress version.
Meanwhile, other changes made this existing problem noticeable, and each time we set a preset color on the pullquote default style, the block becomes invalid.
This PR addresses the problem by on the default style even for preset colors setting the customMainColor attribute, instead of using the default color setting mechanism. This allows the color value to be directly available on the save function, so the function can be pure and depends on its attributes only.
How has this been tested?
I added a pull-quote block; I wrote some text, and I choose a preset color.
I added another pull-quote block; I wrote some text; I changed the block style to the solid color; I chose a preset color and verified it the editor applied it as a background; I changed the block style back to the default.
I saved the post with the two blocks and reloaded the editor and verified the blocks continue to be valid (on master they are not).