File tree Expand file tree Collapse file tree 4 files changed +11
-3
lines changed Expand file tree Collapse file tree 4 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,8 @@ <h2>Selection list</h2>
109
109
110
110
< mat-selection-list #groceries [ngModel] ="selectedOptions "
111
111
(ngModelChange) ="onSelectedOptionsChange($event) "
112
- (change) ="changeEventCount = changeEventCount + 1 ">
112
+ (change) ="changeEventCount = changeEventCount + 1 "
113
+ [disabled] ="selectionListDisabled ">
113
114
< h3 mat-subheader > Groceries</ h3 >
114
115
115
116
< mat-list-option value ="bananas " checkboxPosition ="before "> Bananas</ mat-list-option >
@@ -121,6 +122,7 @@ <h3 mat-subheader>Groceries</h3>
121
122
< p > Selected: {{selectedOptions | json}}</ p >
122
123
< p > Change Event Count {{changeEventCount}}</ p >
123
124
< p > Model Change Event Count {{modelChangeEventCount}}</ p >
125
+ < mat-checkbox [(ngModel)] ="selectionListDisabled "> Disable Selection List</ mat-checkbox >
124
126
125
127
< p >
126
128
< button mat-raised-button (click) ="groceries.selectAll() "> Select all</ button >
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ export class ListDemo {
59
59
60
60
thirdLine : boolean = false ;
61
61
infoClicked : boolean = false ;
62
+ selectionListDisabled : boolean = false ;
62
63
63
64
selectedOptions : string [ ] = [ 'apples' ] ;
64
65
changeEventCount : number = 0 ;
Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ $mat-list-item-inset-divider-offset: 72px;
254
254
}
255
255
256
256
.mat-list-option {
257
- & :not ([ disabled ] ) {
257
+ & :not (.mat-list-item- disabled ) {
258
258
cursor : pointer ;
259
259
}
260
260
}
Original file line number Diff line number Diff line change @@ -283,7 +283,8 @@ export class MatListOption extends _MatListOptionMixinBase
283
283
'(focus)' : 'focus()' ,
284
284
'(blur)' : '_onTouched()' ,
285
285
'(keydown)' : '_keydown($event)' ,
286
- '[attr.aria-disabled]' : 'disabled.toString()' } ,
286
+ '[attr.aria-disabled]' : 'disabled.toString()' ,
287
+ } ,
287
288
template : '<ng-content></ng-content>' ,
288
289
styleUrls : [ 'list.css' ] ,
289
290
encapsulation : ViewEncapsulation . None ,
@@ -390,6 +391,10 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
390
391
391
392
/** Passes relevant key presses to our key manager. */
392
393
_keydown ( event : KeyboardEvent ) {
394
+ if ( this . disabled ) {
395
+ return ;
396
+ }
397
+
393
398
switch ( event . keyCode ) {
394
399
case SPACE :
395
400
case ENTER :
You can’t perform that action at this time.
0 commit comments