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

feat: add layout improvements behind feature flag #8552

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sissbruecker
Copy link
Contributor

Adds the following improvements to vaadin-horizontal-layout and vaadin-vertical-layout:

  • When using setFullWidth, setFullHeight or setFullSize, users typically expect those children to take up the remaining space in the layout, rather than have exactly the same size as the layout itself. In that case apply flex: 1 to make them take up the remaining space.
  • Nested layouts that are supposed to take up the remaining space may not shrink because the size of their contents is larger than the remaining space in the layout. So specifically for other layout components, also apply min-width: 0 to allow them to shrink to the remaining available space.

The improvements are behind a feature flag as they may alter existing layouts, so for now we allow users to try them out.

Part of vaadin/flow-components#6998

Comment on lines +35 to +38
::slotted([style^='width: 100%']),
::slotted([style*=' width: 100%']) {
flex: 1;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We decided to go with this approach instead customizing flex using a custom CSS property. Using a custom property would have meant to apply this rule to all children, which could then result in overwriting defaults that a component might have defined in their shadow root styles. That is because a rule like flex: var(--_layout-flex) reverts the flex value to initial if --_layout-flex is not defined.

Comment on lines +40 to +43
::slotted(vaadin-horizontal-layout),
::slotted(vaadin-vertical-layout) {
min-width: 0;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similarly, changing the min size on all children is not desirable. For example, for grid we explicitly added a min-height in the shadow root styles, which should not be overridden by the layout. Other components have an explicit min size as well. As the problem with children not being able to shrink due to their content mostly involves nested layouts we chose to limit this to these two components for now.

@sissbruecker sissbruecker marked this pull request as ready for review January 23, 2025 07:40
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.

1 participant