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/material/list/selection-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('MatSelectionList without forms', () => {
SelectionListWithOnlyOneOption,
SelectionListWithIndirectChildOptions,
SelectionListWithSelectedOptionAndValue,
SelectionListWithIndirectDescendantLines,
],
});

Expand Down Expand Up @@ -603,6 +604,14 @@ describe('MatSelectionList without forms', () => {
expect(listItemEl.componentInstance.value).toBe(componentFixture.componentInstance.itemValue);
});

it('should pick up indirect descendant lines', () => {
const componentFixture = TestBed.createComponent(SelectionListWithIndirectDescendantLines);
componentFixture.detectChanges();

const option = componentFixture.nativeElement.querySelector('mat-list-option');
expect(option.classList).toContain('mat-2-line');
});

});

describe('with list option selected', () => {
Expand Down Expand Up @@ -1445,3 +1454,18 @@ class SelectionListWithIcon {
class SelectionListWithIndirectChildOptions {
@ViewChildren(MatListOption) optionInstances: QueryList<MatListOption>;
}

// Note the blank `ngSwitch` which we need in order to hit the bug that we're testing.
@Component({
template: `
<mat-selection-list>
<mat-list-option>
<ng-container [ngSwitch]="true">
<h3 mat-line>Item</h3>
<p mat-line>Item description</p>
</ng-container>
</mat-list-option>
</mat-selection-list>`
})
class SelectionListWithIndirectDescendantLines {
}
2 changes: 1 addition & 1 deletion src/material/list/selection-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class MatListOption extends _MatListOptionMixinBase implements AfterConte

@ContentChild(MatListAvatarCssMatStyler) _avatar: MatListAvatarCssMatStyler;
@ContentChild(MatListIconCssMatStyler) _icon: MatListIconCssMatStyler;
@ContentChildren(MatLine) _lines: QueryList<MatLine>;
@ContentChildren(MatLine, {descendants: true}) _lines: QueryList<MatLine>;

/** DOM element containing the item's text. */
@ViewChild('text') _text: ElementRef;
Expand Down