Skip to content

fix(selection-list): incorrect cursor if disabled #9963

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

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
4 changes: 3 additions & 1 deletion src/demo-app/list/list-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ <h2>Selection list</h2>

<mat-selection-list #groceries [ngModel]="selectedOptions"
(ngModelChange)="onSelectedOptionsChange($event)"
(change)="changeEventCount = changeEventCount + 1">
(change)="changeEventCount = changeEventCount + 1"
[disabled]="selectionListDisabled">
<h3 mat-subheader>Groceries</h3>

<mat-list-option value="bananas" checkboxPosition="before">Bananas</mat-list-option>
Expand All @@ -121,6 +122,7 @@ <h3 mat-subheader>Groceries</h3>
<p>Selected: {{selectedOptions | json}}</p>
<p>Change Event Count {{changeEventCount}}</p>
<p>Model Change Event Count {{modelChangeEventCount}}</p>
<mat-checkbox [(ngModel)]="selectionListDisabled">Disable Selection List</mat-checkbox>

<p>
<button mat-raised-button (click)="groceries.selectAll()">Select all</button>
Expand Down
1 change: 1 addition & 0 deletions src/demo-app/list/list-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class ListDemo {

thirdLine: boolean = false;
infoClicked: boolean = false;
selectionListDisabled: boolean = false;

selectedOptions: string[] = ['apples'];
changeEventCount: number = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/list/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ $mat-list-item-inset-divider-offset: 72px;
}

.mat-list-option {
&:not([disabled]) {
&:not(.mat-list-item-disabled) {
cursor: pointer;
}
}
7 changes: 6 additions & 1 deletion src/lib/list/selection-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ export class MatListOption extends _MatListOptionMixinBase
'(focus)': 'focus()',
'(blur)': '_onTouched()',
'(keydown)': '_keydown($event)',
'[attr.aria-disabled]': 'disabled.toString()'},
'[attr.aria-disabled]': 'disabled.toString()',
},
template: '<ng-content></ng-content>',
styleUrls: ['list.css'],
encapsulation: ViewEncapsulation.None,
Expand Down Expand Up @@ -390,6 +391,10 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu

/** Passes relevant key presses to our key manager. */
_keydown(event: KeyboardEvent) {
if (this.disabled) {
return;
}

switch (event.keyCode) {
case SPACE:
case ENTER:
Expand Down