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

Fixed flexBasis defaulting to 0%. Fix cyclic dependency with PickerIt… #1265

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('StyleSheet/createReactDOMStyle', () => {
display: 'flex',
flexGrow: 0,
flexShrink: 0,
flexBasis: '0%'
flexBasis: 'auto'
});
});

Expand All @@ -88,16 +88,20 @@ describe('StyleSheet/createReactDOMStyle', () => {
display: 'flex',
flexGrow: 1,
flexShrink: 1,
flexBasis: '0%'
flexBasis: '0%',
minWidth: 'auto',
minHeight: 'auto'
});
});

test('flex: 10', () => {
expect(createReactDOMStyle({ display: 'flex', flex: 10 })).toEqual({
display: 'flex',
flexGrow: 10,
flexShrink: 1,
flexBasis: '0%'
flexShrink: 10,
flexBasis: '0%',
minWidth: 'auto',
minHeight: 'auto'
});
});

Expand All @@ -123,15 +127,19 @@ describe('StyleSheet/createReactDOMStyle', () => {
expect(createReactDOMStyle({ display: 'flex', flexShrink: 1 })).toEqual({
display: 'flex',
flexShrink: 1,
flexBasis: 'auto'
flexBasis: '0%',
minWidth: 'auto',
minHeight: 'auto'
});

// can flex-shrink override the 'flex' expansion?
expect(createReactDOMStyle({ display: 'flex', flex: 1, flexShrink: 2 })).toEqual({
display: 'flex',
flexGrow: 1,
flexShrink: 2,
flexBasis: '0%'
flexBasis: '0%',
minWidth: 'auto',
minHeight: 'auto'
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,23 @@ const createReducer = (style, styleProps) => {
if (style.flexShrink == null) {
resolvedStyle.flexShrink = 0;
}
if (style.flexBasis == null) {
resolvedStyle.flexBasis = 'auto';

if (!style.flexBasis) {
if (style.flexShrink || style.flexGrow) {
resolvedStyle.flexBasis = '0%';

// 0 or any other flasy set to auto
if (!style.minWidth) {
resolvedStyle.minWidth = 'auto';
}

// 0 or any other flasy set to auto
if (!style.minHeight) {
resolvedStyle.minHeight = 'auto';
}
} else {
resolvedStyle.flexBasis = 'auto';
}
}
}
break;
Expand All @@ -212,12 +227,26 @@ const createReducer = (style, styleProps) => {
case 'flex': {
if (value > 0) {
resolvedStyle.flexGrow = value;
resolvedStyle.flexShrink = 1;
resolvedStyle.flexBasis = '0%';
resolvedStyle.flexShrink = value;

// 0 or any other flasy set to 0%
if (!style.flexBasis) {
resolvedStyle.flexBasis = '0%';
}

// 0 or any other flasy set to auto
if (!style.minWidth && resolvedStyle.flexBasis === '0%') {
resolvedStyle.minWidth = 'auto';
}

// 0 or any other flasy set to auto
if (!style.minHeight && resolvedStyle.flexBasis === '0%') {
resolvedStyle.minHeight = 'auto';
}
} else if (value === 0) {
resolvedStyle.flexGrow = 0;
resolvedStyle.flexShrink = 0;
resolvedStyle.flexBasis = '0%';
resolvedStyle.flexBasis = 'auto';
} else if (value === -1) {
resolvedStyle.flexGrow = 0;
resolvedStyle.flexShrink = 1;
Expand Down