Skip to content

bug(mat-selection-list): cannot change disabled status via @Input() disabled after programmatically change it  #12107

@julianobrasil

Description

@julianobrasil

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Change disabled state programmatically (via setDisabledState) and via @Input() disabled

What is the current behavior?

If you set the disabled programmatically, you cannot change it via @Input() disabled anymore.

If you have:

<mat-selection-list #shoes="matSelectionList" [disabled]="_listDisabled">
  <mat-list-option *ngFor="let shoe of typesOfShoes">
    {{shoe}}
  </mat-list-option>
</mat-selection-list>

And you do:

@ViewChild('shoes') _matSelectionList: MatSelectionList;
_listDisabled = false;
...
this._matSelectionList.setDisabledState(true);

the list is disabled (you cannot select any option) no matter what the value of _listDisabled is after executing this._matSelectionList.setDisabledState(true).

What are the steps to reproduce?

Here you have a Stackblitz demo

image

What is the use-case or motivation for changing an existing behavior?

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Material 6.3.2

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions