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

fix refresh on remove #2008

Merged
merged 5 commits into from
Mar 10, 2023
Merged

fix refresh on remove #2008

merged 5 commits into from
Mar 10, 2023

Conversation

willmcgugan
Copy link
Collaborator

Fixes #2007

@willmcgugan willmcgugan marked this pull request as draft March 9, 2023 15:48
Comment on lines -2201 to +2202
self.refresh(layout=True)
if parent.styles.auto_dimensions:
parent.refresh(layout=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to refresh the layout of the parent, regardless of whether they have auto dimensions or not?
Imagine the parent has fixed dimensions but the children have relative dimensions (e.g., fr units).
Don't we need the refresh to make sure the children make use of the space that was just made available?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto dimensions and relative units kind of cancel each other out.

Consider a container with auto height and a single child with height 1fr. The widget needs to know the height of the container, but the container needs to know the height of the child. So auto height considers all relative dimensions to be zero. It will still respect minimums, so essentially what it calculates is the minimal value which satisfies all constraints.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's interesting.
Up until now, I interpreted 1fr to mean that it would expand as much as possible while also respecting relative ratios to other widgets with fr dimensions.
Then, if the parent has auto and the child has 1fr, the child should look at the grandparent to find the maximum size it can occupy and the parent would expand to that size.
This is the behaviour I find more consistent with the interaction between absolute sizes and 1fr.
If a parent has a fixed size and the child has 1fr, the child will expand as much as possible. Hence, I have been taking the "expand as much as possible" as the interpretation of 1fr, which I don't think should fall apart when the parent is auto.

@davep
Copy link
Contributor

davep commented Mar 9, 2023

Not a blocker to approval, but I wonder if we should have a snapshot test for this?

@willmcgugan willmcgugan marked this pull request as ready for review March 9, 2023 21:40
@willmcgugan willmcgugan merged commit d3bdaf8 into main Mar 10, 2023
@willmcgugan willmcgugan deleted the refresh-on-remove branch March 10, 2023 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If you remove a child from a Vertical that is height: auto the Vertical doesn't shrink in heigh
3 participants