-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Stack] Fix default flexDirection
value with responsive prop
#33549
Conversation
flexDirection
should be usedflexDirection
value with responsive prop
@@ -44,6 +44,7 @@ const getSideFromDirection = (direction) => { | |||
export const style = ({ ownerState, theme }) => { | |||
let styles = { | |||
display: 'flex', | |||
flexDirection: typeof ownerState.direction === 'string' ? ownerState.direction : 'column', |
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.
Would this work? It seems to be what's missing, I assume the typeof ownerState.direction === 'string' ? ownerState.direction
logic duplicates with the one in handleBreakpoints
?
flexDirection: typeof ownerState.direction === 'string' ? ownerState.direction : 'column', | |
flexDirection: 'column', |
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.
I can confirm that you are right. flexDirection: 'column'
seems enough. Made the change and added a test.
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.
👍 Nice fix!
Problem:
direction
prop receives a responsive value such that it doesn't start with the smallest breakpoint, such asdirection={{ lg: 'row' }}
,flexDirection
isn't specified for breakpoints belowlg
and hence it is set to the default value of flexbox, which isrow
.Solution:
StackRoot
'sflexDirection
property toownerState.direction
if it is a string, or simply tocolumn
.direction
values are provided, thisflexDirection
property will be overridden.Codesandboxes:
Before
After