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

Correct ImageView handling of flex=1 sizing #2276

Merged
merged 4 commits into from
Dec 14, 2023

Conversation

freakboy3742
Copy link
Member

Fixes #2275.

The documentation for ImageView suggests that image should shrink if they're marked flex=1. However, the imposed size constraint of at_least(size) prevents shrinking.

This PR changes the at_least constraints to all be at_least(0), which allows images to reduce in size in that axis. Any explicit or undeclared image size continues to be handled as before.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@mhsmith
Copy link
Member

mhsmith commented Dec 13, 2023

I agree this is better, but the previous behavior seems to be implied by the documentation saying "with a minimum size in the main axis matching the size of the image in the main axis". Should that be removed, or is it referring to something else?

@freakboy3742
Copy link
Member Author

I agree this is better, but the previous behavior seems to be implied by the documentation saying "with a minimum size in the main axis matching the size of the image in the main axis". Should that be removed, or is it referring to something else?

Looks like the description was consistent with the old implementation, but the old implementation was wrong. The object-fit: contain addition to the interpretation of ImageViews seems pretty unambiguous that images should shrink, and my testing with HTML bears this out.

If I had to guess at why the initial implementation implemented the minimum size - browser windows enforce a minimum size, and the window refusing to shrink can make it see that there might be a correlation between an image's size and the layout. However, if you use Chrome's debugger for responsive layouts, you can control the size of the viewport independent of the window, and pretty clearly demonstrate that there's no minimum size on images.

I've updated the docs to reflect the new state of the code.

@freakboy3742 freakboy3742 merged commit e09fadd into beeware:main Dec 14, 2023
35 checks passed
@freakboy3742 freakboy3742 deleted the image-shrink branch December 14, 2023 21:30
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.

ImageView doesn't shrink images to fit
2 participants