-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Cover: Block may invalidate with optimized styles #28497
Comments
Thanks Jon, I'll look into this. Block validation seems to happen in this file: https://github.com/WordPress/gutenberg/blob/c31555d4cec541db929ee5f63b900c6577513272/packages/blocks/src/api/validation/index.js I think we can add some logic for the |
|
Fortunately, invalidation seems to compare normalized values. We basically 'just' need to add the relevant logic to gutenberg/packages/blocks/src/api/validation/index.js Lines 328 to 342 in c31555d
For comparison, here's what CSSTidy does: https://github.com/Automattic/jetpack/blob/ece061248c19609e58fd67ba3ff69d850e6780e6/projects/plugins/jetpack/modules/custom-css/csstidy/class.csstidy_optimise.php#L373-L379 We might want to emulate that. It uses |
I believe this is the canonical source for |
This seems a bit convoluted and would need an exception to handle
|
Description
The Cover block with a focal point will generate some HTML like the following:
When a simple CSS optimization plugin runs on post save (for example, applying this to style attributes), it removes the redundant
%
from0%
. The following post content is stored to the database:When the editor is refreshed, the post content is invalid. The CSS is semantically the same, but the missing redundant
%
causes block invalidation to occur. The block should be resilient to this change as the style is semantically identical.Note that #28487 makes this issue much more likely to be encountered as a
0
value must be picked in the focal point picker.Step-by-step reproduction instructions
You need to run a css optimization plugin that applies the
%
removal optimization on post save.Expected behaviour
There should be no block invalidation.
Actual behaviour
The block is invalidated.
WordPress information
The text was updated successfully, but these errors were encountered: