-
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
Batching gap styles is causing Block Spacing settings to fail #43046
Comments
@aristath @ramonjd @andrewserong sorry for the ping, but I know you all have been working on the style engine. 🙏 |
Thanks for reporting, @ndiego ! I'll add it to the list of TODOs |
For this individual case, updating the CSS rule registration to this would work: array_push(
$layout_styles,
array(
'selector' => "$selector > *,$selector > * + *",
'declarations' => array(
'margin-block-end' => '0',
),
),
array(
'selector' => "$selector > * + *",
'declarations' => array(
'margin-block-start' => $gap_value,
),
)
); I have a PR up for this However, this PR doesn't address the root cause, for which I don't know if there should be a "fix"1 the style engine combines selectors and prints them, not in the order in which the styles are registered, but at the bottom of the stylesheet. @aristath will probably have a neat trick up his sleeve 😄, but I'd guess that it'd be hard if not impossible to respect the order of individual selectors when combining rules. Maybe in this instance we accept it as a "feature" and document the behaviour. After that it should be up to the consumer to:
However, the loud, little paranoid person inside me is saying that we might encounter more of this type of thing, and maybe we should be beefing up our test cases before we unleash the optimization feature onto the world in 6.1. In anticipation that the discussion moves in that direction I've thrown up a PR to temporarily disable optimization: Footnotes
|
Adding a thought from @andrewserong in relation to any optimization/combination we perform on the backend:
It makes sense if we want to ensure that the editor and frontend are 1:1. I guess it depends. If our backend code has good coverage, then maybe not everything. 🤷 It would also mean we'd have to port PHP code to JS, and maintain both. But we have to mostly do that anyway for the editor and frontend designs to be (close to) the same. |
Thanks @ramonjd — I don't have a strong opinion on it, but was curious what folks think. From my perspective, I think it's more important for the site frontend's CSS to be optimised for performance rather than what's happening in the editor, where the optimisation itself could slow things down slightly while making adjustments. The main thought I had was whether or not it's important to try to ensure we don't have wildly different implementations where it's difficult to get the same practical styling results in the editor vs site frontend, since sometimes those bugs can be difficult to diagnose.
I think that's probably the bigger concern — if there's no real performance benefit to implementing a JS version, then trying to do so might just be creating more work that isn't needed. 🤔 |
That should not be necessary... The CSS optimizations we do on the frontend should be minimally invasive and shouldn't cause any issues. If they do, then it's because the CSS we write is extremely fragile and the CSS itself should be fixed! |
|
tested and that fixes the issue 👍 |
Description
It looks like since the introduction of #42452, block spacing settings are applied incorrectly when batched.
In looking at the original code, the order is important.
However, when multiple containers with custom block spacing get batched, the batched
$selector > *
styles can get placed after the$selector > * + *
styles.Step-by-step reproduction instructions
$selector > *
styles are rendering after the$selector > * + *
styles which gives them higher priority.Screenshots, screen recording, code snippet
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: