-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix a responsive container issue for sized boxes #7565
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
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thank you Mike.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, I'm going to give a final pass on this Monday just to make sure I didn't miss anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
This dependency PR got merged so there are snapshot conflicts |
With the initial responsive container implementation, it didn't track fixed Box sizes correctly.
What does this PR do?
This moves the
container-type
CSS style from a wrapping div to the actual StyledBox div and uses the forwarded ref to track the size of the StyledBox. This size is used to set the breakpoint value provided in the ResponsiveContext at this level as well as the@container
query for adjusting various edge sizes such for responsive breakpoint behavior.The generated CSS class names on Box components changed due to the addition of the potential
container-type
style even when it doesn't add the style. I tried a few ways to avoid having it change the actual CSS class name although it still causes the name to be different.Note: The Box test for
as
being a function was giving a warning (thrown as an exception) because refs in that case apparently have no effect. Anytime we useuseForwardedRef()
it always creates a ref. So if in those situations if there is anas
property that is a function it will throw that warning/error if we pass that ref to the styled component with theas
property defined. There is no issue if theas
is a string. So in Grommet as it exists prior to this PR, the following will fail:So for any component that is also passed
as
that is a function, it cannot be passed a ref or internally cause a ref to be passed via useForwardedRef (whether or not the component itself was passed a ref.)In this responsive container use case we simply won't attempt to useForwardedRef if
as
is a function and in that case the container can't really be declaredresponsive="container"
Where should the reviewer start?
Box.js
What testing has been done on this PR?
Storybook and manual responsive containers
How should this be manually tested?
Storybook Layout/Box/Responsive container and
Do Jest tests follow these best practices?
screen
is used for querying.asFragment()
is used for snapshot testing.Any background context you want to provide?
What are the relevant issues?
Screenshots (if appropriate)
Do the grommet docs need to be updated?
Should this PR be mentioned in the release notes?
Is this change backwards compatible or is it a breaking change?