Skip to content
Open
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
4 changes: 4 additions & 0 deletions src/material/list/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ $fallbacks: m3-list.get-tokens();
.mdc-checkbox {
opacity: token-utils.slot(list-list-item-disabled-label-text-opacity, $fallbacks);
}

.mdc-radio {
cursor: auto;
}
}

// In Angular Material we put the avatar class directly on the .mdc-list-item__start element,
Expand Down
32 changes: 16 additions & 16 deletions src/material/list/list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ class BaseTestList {
</a>
</mat-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ListWithOneAnchorItem extends BaseTestList {
// This needs to be declared directly on the class; if declared on the BaseTestList superclass,
Expand All @@ -433,7 +433,7 @@ class ListWithOneAnchorItem extends BaseTestList {
</a>
</mat-nav-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class NavListWithOneAnchorItem extends BaseTestList {
@ViewChildren(MatListItem) listItems!: QueryList<MatListItem>;
Expand All @@ -452,7 +452,7 @@ class NavListWithOneAnchorItem extends BaseTestList {
}
</mat-nav-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class NavListWithActivatedItem extends BaseTestList {
@ViewChildren(MatListItem) listItems!: QueryList<MatListItem>;
Expand All @@ -471,7 +471,7 @@ class NavListWithActivatedItem extends BaseTestList {
</button>
</mat-action-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ActionListWithoutType extends BaseTestList {
@ViewChildren(MatListItem) listItems!: QueryList<MatListItem>;
Expand All @@ -487,7 +487,7 @@ class ActionListWithoutType extends BaseTestList {
</button>
</mat-action-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ActionListWithType extends BaseTestList {
@ViewChildren(MatListItem) listItems!: QueryList<MatListItem>;
Expand All @@ -501,7 +501,7 @@ class ActionListWithType extends BaseTestList {
}
</mat-action-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ActionListWithDisabledList extends BaseTestList {
disableList = true;
Expand All @@ -515,7 +515,7 @@ class ActionListWithDisabledList extends BaseTestList {
</button>
</mat-action-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ActionListWithDisabledItem extends BaseTestList {
@ViewChild(MatListItem) buttonItem!: MatListItem;
Expand All @@ -530,7 +530,7 @@ class ActionListWithDisabledItem extends BaseTestList {
</mat-list-item>
</mat-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ListWithOneItem extends BaseTestList {}

Expand All @@ -546,7 +546,7 @@ class ListWithOneItem extends BaseTestList {}
}
</mat-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ListWithTwoLineItem extends BaseTestList {}

Expand All @@ -562,7 +562,7 @@ class ListWithTwoLineItem extends BaseTestList {}
}
</mat-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ListWithThreeLineItem extends BaseTestList {}

Expand All @@ -578,7 +578,7 @@ class ListWithThreeLineItem extends BaseTestList {}
</mat-list-item>
</mat-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ListWithAvatar extends BaseTestList {}

Expand All @@ -593,7 +593,7 @@ class ListWithAvatar extends BaseTestList {}
}
</mat-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ListWithItemWithCssClass extends BaseTestList {}

Expand All @@ -611,7 +611,7 @@ class ListWithItemWithCssClass extends BaseTestList {}
}
</mat-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ListWithDynamicNumberOfLines extends BaseTestList {}

Expand All @@ -623,7 +623,7 @@ class ListWithDynamicNumberOfLines extends BaseTestList {}
}
</mat-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ListWithMultipleItems extends BaseTestList {}

Expand All @@ -635,7 +635,7 @@ class ListWithMultipleItems extends BaseTestList {}
<mat-list-item>Three</mat-list-item>
</mat-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ListWithDisabledItems {
firstItemDisabled = false;
Expand All @@ -645,6 +645,6 @@ class ListWithDisabledItems {
@Component({
template: `<mat-list-item></mat-list-item>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class StandaloneListItem {}
53 changes: 37 additions & 16 deletions src/material/list/selection-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,17 @@ describe('MatSelectionList without forms', () => {
expect(selectList.selected.length).toBe(0);
});

it('should not show a pointer cursor around radios in disabled single-selection lists', () => {
fixture.destroy();

const singleSelectionFixture = TestBed.createComponent(DisabledSingleSelectionList);
singleSelectionFixture.detectChanges();

const radio = singleSelectionFixture.nativeElement.querySelector('.mdc-radio')!;

expect(getComputedStyle(radio).cursor).toBe('auto');
});

it('should update state of options if list state has changed', () => {
const testOption = listOption[2].componentInstance as MatListOption;

Expand Down Expand Up @@ -1699,7 +1710,7 @@ describe('MatSelectionList with forms', () => {
}
</mat-selection-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithListOptions {
showLastOption = true;
Expand Down Expand Up @@ -1728,7 +1739,7 @@ class SelectionListWithListOptions {
</mat-list-option>
</mat-selection-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithCheckboxPositionAfter {}

Expand All @@ -1749,20 +1760,30 @@ class SelectionListWithCheckboxPositionAfter {}
</mat-list-option>
</mat-selection-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithListDisabled {
disabled: boolean = true;
}

@Component({
template: `
<mat-selection-list [disabled]="true" [multiple]="false">
<mat-list-option>Inbox</mat-list-option>
</mat-selection-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Default,
})
class DisabledSingleSelectionList {}

@Component({
template: `
<mat-selection-list>
<mat-list-option [disabled]="disableItem">Item</mat-list-option>
</mat-selection-list>
`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithDisabledOption {
disableItem: boolean = false;
Expand All @@ -1777,7 +1798,7 @@ class SelectionListWithDisabledOption {
<mat-list-option>Not selected - Item #4</mat-list-option>
</mat-selection-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithSelectedOption {}

Expand All @@ -1788,7 +1809,7 @@ class SelectionListWithSelectedOption {}
<mat-list-option [selected]="true">Pre-selected - Item #2</mat-list-option>
</mat-selection-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SingleSelectionListWithSelectedOption {}

Expand All @@ -1798,7 +1819,7 @@ class SingleSelectionListWithSelectedOption {}
<mat-list-option [selected]="true" [value]="itemValue">Item</mat-list-option>
</mat-selection-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithSelectedOptionAndValue {
itemValue = 'item1';
Expand All @@ -1815,7 +1836,7 @@ class SelectionListWithSelectedOptionAndValue {
}
</mat-selection-list>`,
imports: [MatListModule, FormsModule, ReactiveFormsModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithModel {
modelChangeSpy = jasmine.createSpy('model change spy');
Expand All @@ -1838,7 +1859,7 @@ class SelectionListWithModel {
}
`,
imports: [MatListModule, FormsModule, ReactiveFormsModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithFormControl {
formControl = new FormControl([] as string[]);
Expand All @@ -1853,7 +1874,7 @@ class SelectionListWithFormControl {
<mat-list-option value="opt2" selected>Option 2</mat-list-option>
</mat-selection-list>`,
imports: [MatListModule, FormsModule, ReactiveFormsModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithPreselectedOption {
selectedOptions!: string[];
Expand All @@ -1866,7 +1887,7 @@ class SelectionListWithPreselectedOption {
<mat-list-option value="opt2" selected>Option 2</mat-list-option>
</mat-selection-list>`,
imports: [MatListModule, FormsModule, ReactiveFormsModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithPreselectedOptionAndModel {
selectedOptions = ['opt1'];
Expand Down Expand Up @@ -1895,7 +1916,7 @@ class SelectionListWithPreselectedFormControlOnPush {
}
</mat-selection-list>`,
imports: [MatListModule, FormsModule, ReactiveFormsModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithCustomComparator {
@ViewChildren(MatListOption) optionInstances!: QueryList<MatListOption>;
Expand All @@ -1918,7 +1939,7 @@ class SelectionListWithCustomComparator {
</mat-selection-list>
`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithAvatar {
togglePosition!: MatListOptionTogglePosition;
Expand All @@ -1934,7 +1955,7 @@ class SelectionListWithAvatar {
</mat-selection-list>
`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithIcon {
togglePosition!: MatListOptionTogglePosition;
Expand All @@ -1950,7 +1971,7 @@ class SelectionListWithIcon {
}
</mat-selection-list>`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListWithIndirectChildOptions {
@ViewChildren(MatListOption) optionInstances!: QueryList<MatListOption>;
Expand All @@ -1963,7 +1984,7 @@ class SelectionListWithIndirectChildOptions {
</mat-selection-list>
`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ListOptionWithTwoWayBinding {
selected = false;
Expand Down
8 changes: 4 additions & 4 deletions src/material/list/testing/list-harness.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ describe('MatSelectionListHarness', () => {
<mat-list class="test-empty"></mat-list>
`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ListHarnessTest {
disableThirdItem = signal(false);
Expand Down Expand Up @@ -567,7 +567,7 @@ class ListHarnessTest {
<mat-action-list class="test-empty"></mat-action-list>
`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class ActionListHarnessTest {
lastClicked!: string;
Expand Down Expand Up @@ -610,7 +610,7 @@ class ActionListHarnessTest {
<mat-nav-list class="test-empty"></mat-nav-list>
`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class NavListHarnessTest {
lastClicked!: string;
Expand Down Expand Up @@ -654,7 +654,7 @@ class NavListHarnessTest {
<mat-selection-list class="test-empty" disabled></mat-selection-list>
`,
imports: [MatListModule],
changeDetection: ChangeDetectionStrategy.Eager,
changeDetection: ChangeDetectionStrategy.Default,
})
class SelectionListHarnessTest {
disableThirdItem = signal(false);
Expand Down
Loading