Skip to content

Commit

Permalink
fix(api): layout with layoutAlign was not responding to reverse direc…
Browse files Browse the repository at this point in the history
…tions

fxLayoutAlign was ignoring reverse flow-directions in peer fxLayout=“row-reverse” configurations.

Fixes #82.
  • Loading branch information
ThomasBurleson committed Jan 4, 2017
1 parent d07f057 commit dde6e87
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/flexbox/api/layout-align.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class LayoutAlignDirective extends BaseFxDirective implements OnInit, OnC
* Cache the parent container 'flex-direction' and update the 'flex' styles
*/
private _onLayoutChange(direction) {
this._layout = (direction || '').toLowerCase().replace('-reverse', '');
this._layout = (direction || '').toLowerCase();
if (!LAYOUT_VALUES.find(x => x === this._layout))
this._layout = 'row';

Expand Down
24 changes: 23 additions & 1 deletion src/lib/flexbox/api/layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import {BreakPointRegistry} from '../../media-query/breakpoints/break-point-regi
import {FlexLayoutModule} from '../_module';

import {customMatchers} from '../../utils/testing/custom-matchers';
import {makeCreateTestComponent, makeExpectDOMFrom, expectNativeEl} from '../../utils/testing/helpers';
import {makeCreateTestComponent, makeExpectDOMFrom, makeExpectDOMForQuery, expectNativeEl} from '../../utils/testing/helpers';

describe('layout directive', () => {
let fixture: ComponentFixture<any>;
let createTestComponent = makeCreateTestComponent(()=> TestLayoutComponent);
let expectDOMFrom = makeExpectDOMFrom(()=> TestLayoutComponent);
let expectDomForQuery = makeExpectDOMForQuery(()=> TestLayoutComponent);
let activateMediaQuery = (alias, allowOverlaps?:boolean) => {
let matchMedia : MockMatchMedia = fixture.debugElement.injector.get(MatchMedia);
matchMedia.activate(alias,allowOverlaps);
Expand Down Expand Up @@ -98,6 +99,27 @@ describe('layout directive', () => {

});

it('should set row-reverse direction for nested fxLayout containers', () => {
let template = `
<div [fxLayout]="direction" (click)="toggleDirection()" class="colored box" >
<div fxFlex="20"> fxFlex="20" </div>
<div fxFlex="60"> outer fxFlex="60"
<div fxLayout="row-reverse" fxLayoutAlign="center center" class="colored box" >
<div fxFlex="20"> inner fxFlex="20" </div>
<div fxFlex="60"> inner fxFlex="60" </div>
<div fxFlex > inner fxFlex </div>
</div>
</div>
<div fxFlex > fxFlex </div>
</div>
`;

expectDomForQuery( template,"[fxLayout='row-reverse']" )
.toHaveCssStyle({
'flex-direction' : 'row-reverse',
});
});

});

describe('with responsive features', () => {
Expand Down

0 comments on commit dde6e87

Please sign in to comment.