Skip to content

Commit

Permalink
fix(fxFlex): fix wrapping in older versions of Safari
Browse files Browse the repository at this point in the history
* add flex basis back if either max or min width/height is set
* related: https://github.com/philipwalton/flexbugs#flexbug-11
* fix demo-app height issue with older Safari
* update tests to reflect new behavior
  • Loading branch information
CaerusKaru authored and ThomasBurleson committed Mar 14, 2018
1 parent 2079aea commit 3809608
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="handle handle-row" ngxSplitHandle>
<i class="material-icons">&#xE25D;</i>
</div>
<div fxFlex.xs="70%" fxFlex.gt-md="50%" fxFlex.lg="60%" ngxSplitArea>
<div fxFlex.xs="70%" fxFlex.gt-md="50%" fxFlex.lg="60%" ngxSplitArea style="height:500px;">
<div fxLayout="column" fxFlexFill ngxSplit="column">
<div fxFlex="50%" ngxSplitArea class="c2r1_body">
<div class="c2r1_header">Column #2 - Row #1</div>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/flex/flex-offset/flex-offset.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('flex-offset directive', () => {
it('should work with percentage values', () => {
componentWithTemplate(`<div fxFlexOffset='17' fxFlex='37'></div>`);
expectNativeEl(fixture).toHaveStyle({
'flex': '1 1 100%',
'flex': '1 1 37%',
'box-sizing': 'border-box',
'margin-left': '17%'
}, styler);
Expand Down
30 changes: 15 additions & 15 deletions src/lib/flex/flex/flex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ describe('flex directive', () => {
fixture.detectChanges();
expectNativeEl(fixture).toHaveStyle({
'max-width': '2%',
'flex': '1 1 100%',
'flex': '1 1 2%',
'box-sizing': 'border-box',
}, styler);
});

it('should work with percentage values', () => {
componentWithTemplate(`<div fxFlex='37%'></div>`);
expectNativeEl(fixture).toHaveStyle({
'flex': '1 1 100%',
'flex': '1 1 37%',
'max-width': '37%',
'box-sizing': 'border-box',
}, styler);
Expand Down Expand Up @@ -456,7 +456,7 @@ describe('flex directive', () => {
expectNativeEl(fixture)
.not.toHaveStyle({
'flex-direction': 'row',
'flex': '1 1 100%',
'flex': '1 1 37%',
'max-height': '37%',
}, styler);
});
Expand All @@ -472,23 +472,23 @@ describe('flex directive', () => {
fixture.detectChanges();
expectEl(queryFor(fixture, '[fxFlex]')[0])
.toHaveStyle({
'flex': '1 1 100%',
'flex': '1 1 37%',
'max-height': '37%',
}, styler);
});

it('should set max-width for `fxFlex="<%val>"`', () => {
componentWithTemplate(`<div fxFlex='37%'></div>`);
expectNativeEl(fixture).toHaveStyle({
'flex': '1 1 100%',
'flex': '1 1 37%',
'max-width': '37%',
}, styler);
});

it('should set max-width for `fxFlex="2%"` usage', () => {
componentWithTemplate(`<div fxFlex='2%'></div>`);
expectNativeEl(fixture).toHaveStyle({
'flex': '1 1 100%',
'flex': '1 1 2%',
'max-width': '2%',
}, styler);
});
Expand All @@ -510,15 +510,15 @@ describe('flex directive', () => {
fixture.detectChanges();

expectNativeEl(fixture).toHaveStyle({
'flex': '1 1 100%',
'flex': '1 1 50%',
'max-width': '50%'
}, styler);

matchMedia.activate('sm', true);
fixture.detectChanges();

expectNativeEl(fixture).toHaveStyle({
'flex': '1 1 100%',
'flex': '1 1 33%',
'max-width': '33%'
}, styler);
});
Expand Down Expand Up @@ -546,9 +546,9 @@ describe('flex directive', () => {
fixture.detectChanges();

nodes = queryFor(fixture, '[fxFlex]');
expectEl(nodes[0]).toHaveStyle({'flex': '1 1 100%', 'max-height': '50%'}, styler);
expectEl(nodes[1]).toHaveStyle({'flex': '1 1 100%', 'max-height': '24.4%'}, styler);
expectEl(nodes[2]).toHaveStyle({'flex': '1 1 100%', 'max-height': '25.6%'}, styler);
expectEl(nodes[0]).toHaveStyle({'flex': '1 1 50%', 'max-height': '50%'}, styler);
expectEl(nodes[1]).toHaveStyle({'flex': '1 1 24.4%', 'max-height': '24.4%'}, styler);
expectEl(nodes[2]).toHaveStyle({'flex': '1 1 25.6%', 'max-height': '25.6%'}, styler);

matchMedia.activate('sm');
fixture.detectChanges();
Expand Down Expand Up @@ -597,9 +597,9 @@ describe('flex directive', () => {
fixture.detectChanges();
nodes = queryFor(fixture, '[fxFlex]');

expectEl(nodes[0]).toHaveStyle({'flex': '1 1 100%', 'max-height': '50%'}, styler);
expectEl(nodes[1]).toHaveStyle({'flex': '1 1 100%', 'max-height': '24.4%'}, styler);
expectEl(nodes[2]).toHaveStyle({'flex': '1 1 100%', 'max-height': '25.6%'}, styler);
expectEl(nodes[0]).toHaveStyle({'flex': '1 1 50%', 'max-height': '50%'}, styler);
expectEl(nodes[1]).toHaveStyle({'flex': '1 1 24.4%', 'max-height': '24.4%'}, styler);
expectEl(nodes[2]).toHaveStyle({'flex': '1 1 25.6%', 'max-height': '25.6%'}, styler);
});

it('should fallback to the default layout from lt-md selectors', () => {
Expand All @@ -621,7 +621,7 @@ describe('flex directive', () => {
nodes = queryFor(fixture, '[fxFlex]');

expectEl(nodes[0]).toHaveStyle({
'flex': '1 1 100%',
'flex': '1 1 50%',
'max-height': '50%'
}, styler);

Expand Down
5 changes: 5 additions & 0 deletions src/lib/flex/flex/flex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ export class FlexDirective extends BaseFxDirective implements OnInit, OnChanges,
'flex': `${grow} ${shrink} ${basis}`
});
}
} else {
// Fix for issue 660
css[hasCalc ? 'flex-basis' : 'flex'] = css[max] ?
(hasCalc ? css[max] : `${grow} ${shrink} ${css[max]}`) :
(hasCalc ? css[min] : `${grow} ${shrink} ${css[min]}`);
}

return extendObject(css, {'box-sizing': 'border-box'});
Expand Down
6 changes: 1 addition & 5 deletions tools/gulp/tasks/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ task(':watch:devapp', () => {
watchFiles(join(flexLayoutPackage.sourceDir, '**/!(*.scss)'), ['flex-layout:build-no-bundles']);
});

task('devapp:deps', execTask(
'npm', ['install'], {cwd: appDir}
));

task(':serve:devapp', ['aot:pre'], execTask(
'ng', ['serve'],
'ng', ['serve', '--port', '4000'],
{cwd: appDir, failOnStderr: true}
));

Expand Down

0 comments on commit 3809608

Please sign in to comment.