Skip to content
Merged
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
24 changes: 24 additions & 0 deletions src/lib/grid-list/grid-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('MatGridList', () => {
GridListWithoutMatchingGap,
GridListWithEmptyDirectionality,
GridListWithRtl,
GridListWithIndirectTileDescendants,
],
});

Expand Down Expand Up @@ -317,6 +318,15 @@ describe('MatGridList', () => {
expect(tile.style.left).toBe('');
expect(tile.style.right).toBe('0px');
});

it('should lay out the tiles if they are not direct descendants of the list', () => {
const fixture = TestBed.createComponent(GridListWithIndirectTileDescendants);
fixture.detectChanges();

const tile = fixture.debugElement.query(By.directive(MatGridTile));
expect(getStyle(tile, 'padding-top')).toBe('200px');
});

});


Expand Down Expand Up @@ -509,3 +519,17 @@ class GridListWithEmptyDirectionality { }
providers: [{provide: Directionality, useValue: {value: 'rtl'}}]
})
class GridListWithRtl { }

@Component({
// Note the blank `ngSwitch` which we need in order to hit the bug that we're testing.
template: `
<div style="width:200px">
<mat-grid-list cols="1">
<ng-container [ngSwitch]="true">
<mat-grid-tile></mat-grid-tile>
</ng-container>
</mat-grid-list>
</div>
`
})
class GridListWithIndirectTileDescendants {}
2 changes: 1 addition & 1 deletion src/lib/grid-list/grid-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class MatGridList implements OnInit, AfterContentChecked {
private _tileStyler: TileStyler;

/** Query list of tiles that are being rendered. */
@ContentChildren(MatGridTile) _tiles: QueryList<MatGridTile>;
@ContentChildren(MatGridTile, {descendants: true}) _tiles: QueryList<MatGridTile>;

constructor(private _element: ElementRef, @Optional() private _dir: Directionality) {}

Expand Down