Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.
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
29 changes: 29 additions & 0 deletions src/lib/api/flexbox/layout-gap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,35 @@ describe('layout-gap directive', () => {

}));

it('should add update gap styles when only 1 row is remaining', async(() => {
let template = `
<div fxLayoutAlign='center center' fxLayoutGap='13px'>
<div fxFlex *ngFor='let row of rows'></div>
</div>
`;
fixture = createTestComponent(template);
fixture.componentInstance.direction = 'row';
fixture.detectChanges();

let nodes = queryFor(fixture, '[fxFlex]');
expect(nodes.length).toEqual(4);

fixture.componentInstance.rows = new Array(1);
fixture.detectChanges();

setTimeout(() => {
// Since the layoutGap directive detects the *ngFor changes by using a MutationObserver, the
// browser will take up some time, to actually announce the changes to the directive.
// (Kudos to @DevVersion)

nodes = queryFor(fixture, '[fxFlex]');
expect(nodes.length).toEqual(1);

expect(nodes[0].nativeElement).not.toHaveStyle({'margin-right': '13px'});
});

}));

it('should apply margin-top for column layouts', () => {
verifyCorrectMargin('column', 'margin-bottom');
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/api/flexbox/layout-gap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class LayoutGapDirective extends BaseFxDirective implements AfterContentI
.filter(el => el.nodeType === 1 && this._getDisplayStyle(el) != 'none');
let numItems = items.length;

if (numItems > 1) {
if (numItems > 0) {
let lastItem = items[numItems - 1];

// For each `element` children EXCEPT the last,
Expand Down