Skip to content

Commit

Permalink
fix(fxLayoutAlign): do not apply cross-axis stretch styles when not n…
Browse files Browse the repository at this point in the history
…eeded (#877)

Closes #876
  • Loading branch information
danmana authored and CaerusKaru committed Nov 5, 2018
1 parent f24b24f commit 3cd5bc1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/lib/flex/layout-align/layout-align.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@ describe('layout-align directive', () => {
'max-height': '100%'
}, styler);
});
it('should not add special styles when the cross-axis is not `stretch`', () => {
createTestComponent(`
<div fxLayout
fxLayoutAlign='center center'>
</div>
`);

expectNativeEl(fixture).not.toHaveStyle({
'max-height': '100%'
}, styler);
});
it('should add special styles for cross-axis `stretch` when layout is `column`', () => {
createTestComponent(`<div fxLayout="column" fxLayoutAlign='end stretch'></div>`);
expectNativeEl(fixture)
Expand Down Expand Up @@ -282,6 +293,25 @@ describe('layout-align directive', () => {
}, styler);
});

it('should undo special styles when cross-axis changes from `stretch` to anything else', () => {
createTestComponent(`
<div fxLayout
fxLayoutAlign='center stretch'
fxLayoutAlign.md='center center'>
</div>
`);

expectNativeEl(fixture).toHaveStyle({
'max-height': '100%'
}, styler);

matchMedia.activate('md');

expectNativeEl(fixture).not.toHaveStyle({
'max-height': '100%'
}, styler);
});

it('should fallback to default styles when the active mediaQuery change is not configured', () => { // tslint:disable-line:max-line-length
createTestComponent(`
<div fxLayout
Expand Down
4 changes: 3 additions & 1 deletion src/lib/flex/layout-align/layout-align.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ export class LayoutAlignDirective extends BaseDirective implements OnInit, OnCha
return extendObject(css, {
'display' : 'flex',
'flex-direction' : this._layout || 'row',
'box-sizing' : 'border-box'
'box-sizing' : 'border-box',
'max-width': null,
'max-height': null,
});
}

Expand Down

0 comments on commit 3cd5bc1

Please sign in to comment.