Refactor responsive behavior to better deal with nested .alignwide and .alignfull blocks.#701
Conversation
|
This one should be a lot cleaner @andersnoren ;-) |
|
@allancole Really sorry for being slow on checking this one – I'm hoping to get to it this evening. Tomorrow morning at the latest. |
|
No worries at all, @andersnoren. It’s actually still a work in progress so feel free to point out anything you find thats out of place when you can 👍. |
|
@allancole I've taken a look now, and I definitely agree that the alignment classes shouldn't break out of the constraints set by any parent elements. There's also a lot of stuff to fix with the alignment classes in the block editor. I have an ever expanding list of adjustments I need to get to this weekend. A concern I have with this approach for the alignment classes is that elements nested in a Is displayed like this: I definitely think users should be able to match the width of the centered content column by nesting blocks within a I tried a solution for getting the nesting to work correctly within the current structure (with a You can find the branch with my tests here: https://github.com/andersnoren/twentytwenty/tree/test/adjust-nested-alignments |
Yup, I definitely understand your concern here and ran into the same thing myself :-). Sometimes I want the Header Block to just be wide or even full, but the editor does not support it in the UI currently. So for me the actual question becomes “How do we make a Header Block wide/full when the editor does not support it in the UI?” One way, is to nest the Header Block in a Group Block as you described above but I view this as a happy accident that only works because the Group Block + nesting didn’t exist in core from the very beginning. It’s tough to follow at first, but allowing the Group Block to influence nested blocks will create a couple of subtle problems for users: (1) How will they know that a Group Block has an effect on the width of its children blocks (especially for blocks that don’t support any width controls)? And (2) how would a user roll it back to normal if they actually prefer the The good thing though its actually super easy to make a Header Block stretch wide/full-width without wrapping it in a Group Block. You can simply add the This solution isn’t easily discoverable, but it’s much closer to giving users explicit control over a Blocks appearance and it can be baked into a Theme Template just like any other setting :-) . It’s counter-intuitive but when you think about it, we wanna make sure users can do pretty much anything they want in the editor. So in most cases, we want to avoid changing the appearance of a given Block because of its context or because it happens to be nested or next to a particular Block. If anything, I think this is a really good case to help convince core to add
Yeah, this is a good point and does feel a bit vulnerable for the reasons you described bit its actually really strict. The CSS says that any and everything that is not I hope I’m not coming across to heavy handed with this response. I’m happy to make this work however you prefer. Just want to make sure all other options and concerns were on the table before a final decision is made 👍 |
|
@andersnoren I fully agree with @allancole, the width of a block shouldn't change because it is inside or outside a group. The user should be able to easily reproduce a simple layout built outside a group (heading, text, image) inside a group. Inserting another group inside a group is not a good solution imo. Currently, when you set a group to be full-width, default width blocks inside are broken:
I think that when nested inside a full-width group:
|
|
@yannickiki, this is still a work-in-progress but I added some changes that get it a little closer to completion. Mostly just need to make sure that the padding on the frontend match the padding in the editor. Once that’s done I’ll ping you for review and hopefully get this merged :-) |
|
@yannickiki, I think this is good to go now. Check it out and let me know if you notice anything off 👍 |
|
@allancole Nice! I just took a look, here a few things:
I’ll continue to check it. |
…make author bio width match original design.
…pdate default marging for non-wide/full alignment blocks.
…o ensure expected appreance in nested blocks.
…o ensure expected appreance in nested blocks in the editor.
|
Hi @allancole 1) On the front-end, there are issues with a) Outside a group (direct children of The max-width should be set to 26rem. Removing the After removing these lines, it looks good on desktop but there are still some issues on devices smaller than 1220px where the quote is outside the screen. For example at 1024px: b) Inside a group 2) There are still vertical margin values which differ from the original design
3) Concerning the full width group, the side padding should be set to 4rem and not 6rem to match the other elements side padding (header, footer, wide blocks are protected from the screen edges by 4rem, full width Cover block has a 4rem side spacing...) 4) There is an issue with paragraphs inside |
|
Since this one is still a bit of a work in progress I think we will need to move it over to trac and considered after WP 5.3 release. When this repo is being archive/closed I can port this PR over to a trac ticket and create a patch file for it with the changes here. |
|
This one is more important than I had realised before now and we should merge this and try tackle any adjustments that it needs today with priority. |
pattonwebz
left a comment
There was a problem hiding this comment.
I am approving this as-is so it can be merged and worked on farther through a followup PR.
|
@yannickiki there have been a number of changes lately, would love to see if you feel better about these, also #994 has some adjustments too. Thanks @allancole for working on this to get it to a better space for group block. |
|
@karmatosed @allancole I’ve tested the latest commits. Unfortunately, all the issues that I’ve mentioned above remain. The most critical is the first one (1a & 1b). To reproduce the issue:
While it’s working for a 1280px screen (like a 13-inch macbook) it’s broken at 360px, 768px, 1980px etc. |
|
Noting that @allancole made a new PR here: #998. This should now soothe the smaller screen issues. |









This change refactors the width logic to better support nested blocks with varying
.alignwideand.alignfullutility classes. This is necessary to retain consistency with the default behavior between the Gutenberg editor and the Twenty Twenty frontend. See #676 for a more detailed description.To Do:
Related Issues
Fixes: #676
Fixes: #965