Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 3809608

Browse files
CaerusKaruThomasBurleson
authored andcommitted
fix(fxFlex): fix wrapping in older versions of Safari
* 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
1 parent 2079aea commit 3809608

File tree

5 files changed

+23
-22
lines changed

5 files changed

+23
-22
lines changed

src/apps/demo-app/src/app/github-issues/issue-266/issue-266.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div class="handle handle-row" ngxSplitHandle>
1818
<i class="material-icons">&#xE25D;</i>
1919
</div>
20-
<div fxFlex.xs="70%" fxFlex.gt-md="50%" fxFlex.lg="60%" ngxSplitArea>
20+
<div fxFlex.xs="70%" fxFlex.gt-md="50%" fxFlex.lg="60%" ngxSplitArea style="height:500px;">
2121
<div fxLayout="column" fxFlexFill ngxSplit="column">
2222
<div fxFlex="50%" ngxSplitArea class="c2r1_body">
2323
<div class="c2r1_header">Column #2 - Row #1</div>

src/lib/flex/flex-offset/flex-offset.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('flex-offset directive', () => {
8686
it('should work with percentage values', () => {
8787
componentWithTemplate(`<div fxFlexOffset='17' fxFlex='37'></div>`);
8888
expectNativeEl(fixture).toHaveStyle({
89-
'flex': '1 1 100%',
89+
'flex': '1 1 37%',
9090
'box-sizing': 'border-box',
9191
'margin-left': '17%'
9292
}, styler);

src/lib/flex/flex/flex.spec.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ describe('flex directive', () => {
190190
fixture.detectChanges();
191191
expectNativeEl(fixture).toHaveStyle({
192192
'max-width': '2%',
193-
'flex': '1 1 100%',
193+
'flex': '1 1 2%',
194194
'box-sizing': 'border-box',
195195
}, styler);
196196
});
197197

198198
it('should work with percentage values', () => {
199199
componentWithTemplate(`<div fxFlex='37%'></div>`);
200200
expectNativeEl(fixture).toHaveStyle({
201-
'flex': '1 1 100%',
201+
'flex': '1 1 37%',
202202
'max-width': '37%',
203203
'box-sizing': 'border-box',
204204
}, styler);
@@ -456,7 +456,7 @@ describe('flex directive', () => {
456456
expectNativeEl(fixture)
457457
.not.toHaveStyle({
458458
'flex-direction': 'row',
459-
'flex': '1 1 100%',
459+
'flex': '1 1 37%',
460460
'max-height': '37%',
461461
}, styler);
462462
});
@@ -472,23 +472,23 @@ describe('flex directive', () => {
472472
fixture.detectChanges();
473473
expectEl(queryFor(fixture, '[fxFlex]')[0])
474474
.toHaveStyle({
475-
'flex': '1 1 100%',
475+
'flex': '1 1 37%',
476476
'max-height': '37%',
477477
}, styler);
478478
});
479479

480480
it('should set max-width for `fxFlex="<%val>"`', () => {
481481
componentWithTemplate(`<div fxFlex='37%'></div>`);
482482
expectNativeEl(fixture).toHaveStyle({
483-
'flex': '1 1 100%',
483+
'flex': '1 1 37%',
484484
'max-width': '37%',
485485
}, styler);
486486
});
487487

488488
it('should set max-width for `fxFlex="2%"` usage', () => {
489489
componentWithTemplate(`<div fxFlex='2%'></div>`);
490490
expectNativeEl(fixture).toHaveStyle({
491-
'flex': '1 1 100%',
491+
'flex': '1 1 2%',
492492
'max-width': '2%',
493493
}, styler);
494494
});
@@ -510,15 +510,15 @@ describe('flex directive', () => {
510510
fixture.detectChanges();
511511

512512
expectNativeEl(fixture).toHaveStyle({
513-
'flex': '1 1 100%',
513+
'flex': '1 1 50%',
514514
'max-width': '50%'
515515
}, styler);
516516

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

520520
expectNativeEl(fixture).toHaveStyle({
521-
'flex': '1 1 100%',
521+
'flex': '1 1 33%',
522522
'max-width': '33%'
523523
}, styler);
524524
});
@@ -546,9 +546,9 @@ describe('flex directive', () => {
546546
fixture.detectChanges();
547547

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

553553
matchMedia.activate('sm');
554554
fixture.detectChanges();
@@ -597,9 +597,9 @@ describe('flex directive', () => {
597597
fixture.detectChanges();
598598
nodes = queryFor(fixture, '[fxFlex]');
599599

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

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

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

src/lib/flex/flex/flex.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ export class FlexDirective extends BaseFxDirective implements OnInit, OnChanges,
286286
'flex': `${grow} ${shrink} ${basis}`
287287
});
288288
}
289+
} else {
290+
// Fix for issue 660
291+
css[hasCalc ? 'flex-basis' : 'flex'] = css[max] ?
292+
(hasCalc ? css[max] : `${grow} ${shrink} ${css[max]}`) :
293+
(hasCalc ? css[min] : `${grow} ${shrink} ${css[min]}`);
289294
}
290295

291296
return extendObject(css, {'box-sizing': 'border-box'});

tools/gulp/tasks/development.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ task(':watch:devapp', () => {
2020
watchFiles(join(flexLayoutPackage.sourceDir, '**/!(*.scss)'), ['flex-layout:build-no-bundles']);
2121
});
2222

23-
task('devapp:deps', execTask(
24-
'npm', ['install'], {cwd: appDir}
25-
));
26-
2723
task(':serve:devapp', ['aot:pre'], execTask(
28-
'ng', ['serve'],
24+
'ng', ['serve', '--port', '4000'],
2925
{cwd: appDir, failOnStderr: true}
3026
));
3127

0 commit comments

Comments
 (0)