-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
[Grid] grid item doesn't respond to grid container's responsive columns correctly #29715
Conversation
@hbjORbj Ready for a review |
// Keep 7 significant numbers. | ||
const width = `${Math.round((size / columnValue) * 10e7) / 10e5}%`; | ||
let more = {}; | ||
function generateGrid({ theme, ownerState }) { |
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.
So the first big change was to convert this method to match generateDirection
and the other generate methods. This allowed me to remember the size from the previously defined breakpoint. So if xs={1}
is specified and not other breakpoints, each breakpoint will get size 1. By doing it here, it won't affect ownerState where we would want sm=false
if sm is not specified.
@kkorach Hey, thanks for your contribution. I edited the description to describe clearly what problem we are solving in this PR. I will review your code in more detail before the end of the day :) |
c122fa2
to
8875d56
Compare
@hbjORbj Made the changes to Grid. I also had to fix a bug in resolveBreakpointValues. It would set the |
What are the next steps, is there anything I need to do? @hbjORbj |
8875d56
to
9b4452f
Compare
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.
@kkorach Thank you for your amazing contribution. I will merge this after one more review from another teammate.
@siriwatknp Argos tests are failing, but as you can see in the codesandboxes below, the two demos (before and after changes of this PR) are actually identical. Do you know why this is happening? Before: |
Can you try updating the branch with the latest master? |
@hbjORbj I might not have time to review it in detail. From your point of view, do you see any tests that might be needed? |
111fbeb
to
28ef1eb
Compare
@kkorach I had a more careful look and I was able to detect unnecessary changes. (1) I reverted your changes in @siriwatknp I added one more test. FYI, there is much less overall change now, so you should be able to review much more easily. |
f8d05e1
to
26659d9
Compare
Update: Ignore this. I was wrong. I think we should approve the Argos failure. Apparently, <PickersToolbarGrid
container
justifyContent="space-between"
className={classes.dateTitleContainer}
direction={isLandscape ? landscapeDirection : 'row'}
alignItems={isLandscape ? 'flex-start' : 'flex-end'}
> |
I haven't looked too deep here, but I don't understand how the changes of the PR are related to using the |
@mnajdova I was wrong about why the argos was failing. Now argos successfully passes. In conclusion, there are only small changes in code. I commented the two places of change. The issue that this PR was originally trying to solve is fixed and can be seen here. @danilo-leal No need to worry about changed demos! |
const width = `${Math.round((size / columnValue) * 10e7) / 10e5}%`; | ||
let more = {}; | ||
export function generateGrid({ theme, ownerState }) { | ||
let size; |
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 PR changed the scope of this variable size
. As a result, the value of previous breakpoint can be used now.
typeof columnsBreakpointValues === 'object' | ||
? columnsBreakpointValues[breakpoint] | ||
: columnsBreakpointValues; | ||
if (columnValue === undefined || columnValue === null) { |
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.
Another addition of this PR. This prevents width
in the next line from being NaN
.
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.
👍 LGTM
Closes #29379
Problem:
Consider
<Grid item xs={1} />
; the 1 column prop does not carry over to the other breakpoints.In
generateGrid
the first few lines arexs={1}
there won't be any breakpoints in ownerState, so it will exit out of the method.As a result, the following two show different behaviours; the first one shows the correct behaviour;
codesandbox
codesandbox