@@ -17,6 +17,7 @@ import {
1717 OnInit ,
1818} from '@angular/core' ;
1919import { MatChip } from './chip' ;
20+ import { MAT_CHIP } from './tokens' ;
2021
2122/** Event object emitted by MatChipOption when selected or deselected. */
2223export class MatChipSelectionChange {
@@ -38,7 +39,7 @@ export class MatChipSelectionChange {
3839 selector : 'mat-basic-chip-option, mat-chip-option' ,
3940 templateUrl : 'chip-option.html' ,
4041 styleUrls : [ 'chip.css' ] ,
41- inputs : [ 'color' , 'disableRipple' , 'tabIndex' ] ,
42+ inputs : [ 'color' , 'disabled' , ' disableRipple', 'tabIndex' ] ,
4243 host : {
4344 'class' : 'mat-mdc-chip mat-mdc-chip-option mdc-evolution-chip mdc-evolution-chip--filter' ,
4445 '[class.mat-mdc-chip-selected]' : 'selected' ,
@@ -64,7 +65,10 @@ export class MatChipSelectionChange {
6465 '[attr.role]' : 'role' ,
6566 '[id]' : 'id' ,
6667 } ,
67- providers : [ { provide : MatChip , useExisting : MatChipOption } ] ,
68+ providers : [
69+ { provide : MatChip , useExisting : MatChipOption } ,
70+ { provide : MAT_CHIP , useExisting : MatChipOption } ,
71+ ] ,
6872 encapsulation : ViewEncapsulation . None ,
6973 changeDetection : ChangeDetectionStrategy . OnPush ,
7074} )
@@ -97,10 +101,7 @@ export class MatChipOption extends MatChip implements OnInit {
97101 return this . _selected ;
98102 }
99103 set selected ( value : BooleanInput ) {
100- if ( this . selectable ) {
101- const coercedValue = coerceBooleanProperty ( value ) ;
102- this . _setSelectedState ( coercedValue , false ) ;
103- }
104+ this . _setSelectedState ( coerceBooleanProperty ( value ) , false ) ;
104105 }
105106 private _selected = false ;
106107
@@ -126,35 +127,26 @@ export class MatChipOption extends MatChip implements OnInit {
126127
127128 /** Selects the chip. */
128129 select ( ) : void {
129- if ( this . selectable ) {
130- this . _setSelectedState ( true , false ) ;
131- }
130+ this . _setSelectedState ( true , false ) ;
132131 }
133132
134133 /** Deselects the chip. */
135134 deselect ( ) : void {
136- if ( this . selectable ) {
137- this . _setSelectedState ( false , false ) ;
138- }
135+ this . _setSelectedState ( false , false ) ;
139136 }
140137
141138 /** Selects this chip and emits userInputSelection event */
142139 selectViaInteraction ( ) : void {
143- if ( this . selectable ) {
144- this . _setSelectedState ( true , true ) ;
145- }
140+ this . _setSelectedState ( true , true ) ;
146141 }
147142
148143 /** Toggles the current selected state of this chip. */
149144 toggleSelected ( isUserInput : boolean = false ) : boolean {
150- if ( this . selectable ) {
151- this . _setSelectedState ( ! this . selected , isUserInput ) ;
152- }
153-
145+ this . _setSelectedState ( ! this . selected , isUserInput ) ;
154146 return this . selected ;
155147 }
156148
157- protected override _handlePrimaryActionInteraction ( ) {
149+ override _handlePrimaryActionInteraction ( ) {
158150 if ( this . selectable && ! this . disabled ) {
159151 this . _setSelectedState ( ! this . selected , true ) ;
160152 }
0 commit comments