@@ -30,11 +30,9 @@ import {
3030 ViewEncapsulation ,
3131} from '@angular/core' ;
3232import {
33- CanDisable ,
3433 CanDisableRipple ,
3534 MatLine ,
3635 MatLineSetter ,
37- mixinDisabled ,
3836 mixinDisableRipple ,
3937} from '@angular/material/core' ;
4038import { ControlValueAccessor , NG_VALUE_ACCESSOR } from '@angular/forms' ;
@@ -43,7 +41,7 @@ import {Subscription} from 'rxjs';
4341
4442/** @docs -private */
4543export class MatSelectionListBase { }
46- export const _MatSelectionListMixinBase = mixinDisableRipple ( mixinDisabled ( MatSelectionListBase ) ) ;
44+ export const _MatSelectionListMixinBase = mixinDisableRipple ( MatSelectionListBase ) ;
4745
4846/** @docs -private */
4947export class MatListOptionBase { }
@@ -238,6 +236,15 @@ export class MatListOption extends _MatListOptionMixinBase
238236 this . _changeDetector . markForCheck ( ) ;
239237 return true ;
240238 }
239+
240+ /**
241+ * Notifies Angular that the option needs to be checked in the next change detection run. Mainly
242+ * used to trigger an update of the list option if the disabled state of the selection list
243+ * changed.
244+ */
245+ _markForCheck ( ) {
246+ this . _changeDetector . markForCheck ( ) ;
247+ }
241248}
242249
243250
@@ -265,7 +272,7 @@ export class MatListOption extends _MatListOptionMixinBase
265272 changeDetection : ChangeDetectionStrategy . OnPush
266273} )
267274export class MatSelectionList extends _MatSelectionListMixinBase implements FocusableOption ,
268- CanDisable , CanDisableRipple , AfterContentInit , ControlValueAccessor , OnDestroy {
275+ CanDisableRipple , AfterContentInit , ControlValueAccessor , OnDestroy {
269276
270277 /** The FocusKeyManager which handles focus. */
271278 _keyManager : FocusKeyManager < MatListOption > ;
@@ -287,6 +294,22 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
287294 */
288295 @Input ( ) compareWith : ( o1 : any , o2 : any ) => boolean ;
289296
297+ /** Whether the selection list is disabled. */
298+ @Input ( )
299+ get disabled ( ) : boolean { return this . _disabled ; }
300+ set disabled ( value : boolean ) {
301+ this . _disabled = coerceBooleanProperty ( value ) ;
302+
303+ // The `MatSelectionList` and `MatListOption` are using the `OnPush` change detection
304+ // strategy. Therefore the options will not check for any changes if the `MatSelectionList`
305+ // changed its state. Since we know that a change to `disabled` property of the list affects
306+ // the state of the options, we manually mark each option for check.
307+ if ( this . options ) {
308+ this . options . forEach ( option => option . _markForCheck ( ) ) ;
309+ }
310+ }
311+ private _disabled : boolean = false ;
312+
290313 /** The currently selected options. */
291314 selectedOptions : SelectionModel < MatListOption > = new SelectionModel < MatListOption > ( true ) ;
292315
@@ -296,6 +319,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
296319 /** Used for storing the values that were assigned before the options were initialized. */
297320 private _tempValues : string [ ] | null ;
298321
322+ /** Subscription to sync value changes in the SelectionModel back to the SelectionList. */
299323 private _modelChanges = Subscription . EMPTY ;
300324
301325 /** View to model callback that should be called if the list or its options lost focus. */
0 commit comments