WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.4k stars 4.16k forks source link

Only apply relative positioning to Group blocks that have negative margin applied. #64276

Open eric-michel opened 1 month ago

eric-michel commented 1 month ago

What problem does this address?

In the last major WP release, all Group blocks (with constrained layout) are given relative positioning. According to the SCSS file, that's because negative margins require it: https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/group/style.scss.

This has broken a couple of our sites by changing the relative parent of some absolute positioned elements. Our theme settings do not even allow for negative margins. In general, it just doesn't seem like good practice to set all containers to relative positioning. This removes a ton of flexibility.

On a broader note, this is another of many examples of over-aggressive CSS changes that unnecessarily break sites and impose a maintenance burden on theme and site developers. Dealing with negative margins could have been dealt with in a way that did not set all Group blocks site-wide to relative positioning. I should not have to worry about the relative parent of my absolute positioned elements spontaneously changing after a WP update.

What is your proposed solution?

Use the style engine to limit relative positioning to Group blocks that actually need it for negative margin handling.

eric-michel commented 3 weeks ago

A little extra context for this issue - @aaronrobertshaw pointed out that the PR for this change included a lot of discussion about adding this relative positioning across all Group blocks. You can find that PR here: https://github.com/WordPress/gutenberg/pull/60347.

I have not had a chance to read through all of that conversation. Had I known that PR was in the works before 6.6 released, I would definitely have objected to such an aggressive change.