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

Align_items doesn't fill space correctly with cross-axis dimension and direction != parent.direction #3274

Open
HalfWhitt opened this issue Mar 21, 2025 · 0 comments
Labels
bug A crash or error in behavior.

Comments

@HalfWhitt
Copy link
Contributor

HalfWhitt commented Mar 21, 2025

Describe the bug

In a box whose cross-axis dimension is set explicitly and whose parent is the opposite direction, align_items = START works correctly, but CENTER and END don't. The children align properly relative to each other, but only within the amount of cross space they would have taken up with START.

Steps to reproduce

  1. Create a box, either a row or a column, and give it children.
  2. Give it a fixed dimension in its cross axis.
  3. Add it as a child of a box with the opposite direction.
  4. Set align_items to either CENTER or END.

Try it out with this example app: https://gist.github.com/HalfWhitt/b8ccc0d93727c49bae0cfe4532c1e599

Expected behavior

The center- or end-aligned children should be placed at the center or end-side of the box.

Screenshots

Image

Image

Image

Environment

I thought this was a new bug at first, but it applies to alignment as well, at least as far back as 0.4.0.

Logs

No response

Additional context

This is just before pass 4 of the layout algorithm:

if use_all_cross:
cross = max(cross, available_cross)

Setting it unconditionally to the larger value ensures that the children move to center/end within the available space. But this, of course, breaks other things... I haven't stared at the algorithm long enough to fully grok the proper fix.

@HalfWhitt HalfWhitt added the bug A crash or error in behavior. label Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

No branches or pull requests

1 participant