Skip to content
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

Flexbox and auto margins layout #46133

Closed
danieldudzic opened this issue Nov 28, 2022 · 3 comments
Closed

Flexbox and auto margins layout #46133

danieldudzic opened this issue Nov 28, 2022 · 3 comments
Labels
[Feature] Layout Layout block support, its UI controls, and style output. [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Type] Bug An existing feature does not function as intended

Comments

@danieldudzic
Copy link

danieldudzic commented Nov 28, 2022

What problem does this address?

I am trying to add a few patterns to the WooCommerce Blocks Product Query block and realized there's currently no good layout solution for the following layout:

Flex_·_Bootstrap

I was trying to achieve the following layout using core blocks:

🔎_Product_Query_Block_–_Figma

Since the product image will have a variable height (which will determine the height of the container), achieving the desired Price product element position is currently not possible without custom code.

What is your proposed solution?

It would be useful if:

  • There was a straightforward way to tweak flexbox behavior of blocks (on per block level, if the parent is using flexbox)
  • The margin block setting would support the auto value

Related issue: #45868

@Thelmachido Thelmachido added [Feature] Layout Layout block support, its UI controls, and style output. [Type] Enhancement A suggestion for improvement. Needs Technical Feedback Needs testing from a developer perspective. [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P labels Dec 6, 2022
@tellthemachines
Copy link
Contributor

With #45364 it's now possible to set width/height on children of (Row/Stack) flex containers, with a fill option that essentially adds flex-grow: 1 to the block, which behaves the same as margin: auto in this context.

In theory, it should be possible to recreate the layout above by creating a Row block with an Image block and a Stack block (with the product info) inside it, then setting the height (under Dimensions) of the "Product title" block to "fill".

The problem is that the Row block has an align-items: center set on it by default, which makes the Stack block inside it not take up full height, so the flex-grow inside it doesn't work.

I'm inclined to label this as a bug; I know the flex-layout has always had a default align-items set on it but am unsure if there's any good reason for that. The risk of removing it is, of course, that existing layouts may depend on it, so it's not clear what the best solution may be.

@tellthemachines tellthemachines added [Type] Bug An existing feature does not function as intended and removed [Type] Enhancement A suggestion for improvement. Needs Technical Feedback Needs testing from a developer perspective. labels Jan 4, 2023
@tellthemachines
Copy link
Contributor

Just thinking we might be able to work around this once we add alignment controls to Row as per #35849, as long as we add a stretch option. It's not super intuitive but might be our best option for not breaking back compat 🤔

@tellthemachines
Copy link
Contributor

With #47134 merged, we can now recreate this layout by:

  • Adding a Row block with an Image block and a Stack block (with the product info) inside it;
  • Setting the vertical alignment on the Row block to stretch ;
  • Setting the setting the height (under Dimensions) of the "Product title" block to "fill".

Screenshot 2023-01-30 at 3 50 14 pm

I'm going to go ahead and close this issue for now; feel free to reopen if anything doesn't work as expected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Layout Layout block support, its UI controls, and style output. [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants