-
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
Allow Spacer block to inherit orientation from layout #36197
Comments
I closed #30590, which duplicated this issue. The current situation seems to be that #36340 fixed the spacer orientation in the navigation block. The bug still exists for the Row variation of the Group block—the spacer is in the wrong orientation still. It can be used to make the row taller, but it won't space items. |
I've come up with a potential fix for this in #39743, which passes the |
@andrewserong initially when I wrote this out I was thinking of setting up layout to always be present as context, instead of having to add it as context manually to each block. If we were to hack the existing code, that would require adding block supports info to the block representation in the store, and possibly providing context for every block by default. I'm not sure if we want to do those things though. Or maybe we could try creating a separate layout context provider? I opened this more to get a discussion going and ideas on if/how this might be possible. If it turns out it's not possible or we don't want to do it, it's probably easier to just manually add the orientation as an attribute in the context provider block, like we do in Navigation. |
Another case where the Spacer block needs to know about parent layout is #38022. |
Thanks for the extra context @tellthemachines! I stumbled upon this issue the backwards way by first having a go at the PR #39743 and then checking to see if there was already an open issue for it 😄 I'm AFK for the rest of this week, but will take a deeper look at the feedback on that PR and in that other linked issue (#38022) to get a better idea of the broader context surrounding passing down layout context once I'm back. In the meantime, if anyone's keen to have a play with it, feel free to take over that PR! 🙂 |
Description
Currently, the Spacer block has the wrong orientation when inside a Row block, because Spacer reads orientation from block context, but Row has orientation defined as part of its layout attribute.
If #36169 goes through, we'll have the same problem when Spacer is a child of Navigation.
While we could try a patch along the lines of
in the parent block's edit function, we'd have to add it to all possible parents of Spacer with configurable orientation, and it could break if anything changes in the layout logic. It would also require a default value, because orientation isn't set explicitly inside layout unless it's changed by the user.
Spacer needs the
orientation
attribute not for styling purposes, but so it can set the direction of its controls, so merely inheriting its parent's layout isn't much use. Ideally we'd be able to provide layout properties as block context, so that Spacer could still read the attribute.Other ideas welcome!
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
No response
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: