Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(grid-list): not picking up indirect descendants #12823

Merged
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