Skip to content

Commit 044a360

Browse files
crisbetommalerba
authored andcommitted
fix(grid-list): not picking up indirect descendant lines (#17530)
Fixes the grid tile header/footer not picking up indirect descendant `mat-line`.
1 parent 5f0f2dc commit 044a360

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/material/grid-list/grid-list.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,14 @@ describe('MatGridList', () => {
475475
expect(footer.nativeElement.classList.contains('mat-2-line')).toBe(true);
476476
});
477477

478+
it('should add class to footers with two indirect descendant lines', () => {
479+
const fixture = createComponent(GridListWithFooterContainingTwoIndirectDescendantLines);
480+
fixture.detectChanges();
481+
482+
const footer = fixture.debugElement.query(By.directive(MatGridTileText))!;
483+
expect(footer.nativeElement.classList).toContain('mat-2-line');
484+
});
485+
478486
it('should not use calc() that evaluates to 0', () => {
479487
const fixture = createComponent(GirdListWithRowHeightRatio);
480488

@@ -784,6 +792,19 @@ class GridListWithFootersWithoutLines { }
784792
</mat-grid-list>`})
785793
class GridListWithFooterContainingTwoLines { }
786794

795+
@Component({template: `
796+
<mat-grid-list cols="1">
797+
<mat-grid-tile>
798+
<mat-grid-tile-footer>
799+
<ng-container [ngSwitch]="true">
800+
<h3 mat-line>First line</h3>
801+
<span mat-line>Second line</span>
802+
</ng-container>
803+
</mat-grid-tile-footer>
804+
</mat-grid-tile>
805+
</mat-grid-list>`})
806+
class GridListWithFooterContainingTwoIndirectDescendantLines { }
807+
787808
@Component({template: `
788809
<mat-grid-list cols="5">
789810
<mat-grid-tile [rowspan]="1" [colspan]="3">1</mat-grid-tile>

src/material/grid-list/grid-tile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class MatGridTile {
7070
encapsulation: ViewEncapsulation.None,
7171
})
7272
export class MatGridTileText implements AfterContentInit {
73-
@ContentChildren(MatLine) _lines: QueryList<MatLine>;
73+
@ContentChildren(MatLine, {descendants: true}) _lines: QueryList<MatLine>;
7474

7575
constructor(private _element: ElementRef<HTMLElement>) {}
7676

0 commit comments

Comments
 (0)