@@ -71,6 +71,7 @@ export class MdChipListChange {
71
71
'[attr.aria-required]' : 'required.toString()' ,
72
72
'[attr.aria-disabled]' : 'disabled.toString()' ,
73
73
'[attr.aria-invalid]' : 'errorState' ,
74
+ '[attr.aria-multiselectable]' : 'true' ,
74
75
'[class.mat-chip-list-disabled]' : 'disabled' ,
75
76
'[class.mat-chip-list-invalid]' : 'errorState' ,
76
77
'[class.mat-chip-list-required]' : 'required' ,
@@ -164,6 +165,7 @@ export class MdChipList implements MdFormFieldControl<any>, ControlValueAccessor
164
165
/** Comparison function to specify which option is displayed. Defaults to object equality. */
165
166
private _compareWith = ( o1 : any , o2 : any ) => o1 === o2 ;
166
167
168
+ /** The array of selected chips inside chip list. */
167
169
get selected ( ) : MdChip [ ] {
168
170
return this . _selectionModel . selected ;
169
171
}
@@ -219,22 +221,23 @@ export class MdChipList implements MdFormFieldControl<any>, ControlValueAccessor
219
221
return this . _chipInput ? this . _chipInput . placeholder : this . _placeholder ;
220
222
}
221
223
222
- /** For FormFieldControl. If any of the chips has focus, or the chip input has focus */
224
+ /** Whether any chips or the mdChipInput inside of this chip-list has focus. */
223
225
get focused ( ) {
224
226
return this . chips . some ( chip => chip . _hasFocus ) ||
225
227
( this . _chipInput && this . _chipInput . focused ) ;
226
228
}
227
229
228
- /** For FormFieldControl. The chip list is empty if there's no chip and there's no input */
230
+ /** Whether this chip- list contains no chips and no mdChipInput. */
229
231
get empty ( ) : boolean {
230
232
return ( ! this . _chipInput || this . _chipInput . empty ) && this . chips . length === 0 ;
231
233
}
232
234
233
- /** For FormFieldControl. The disabled is not depend on chip input */
235
+ /** Whether this chip-list is disabled. */
234
236
@Input ( )
235
237
get disabled ( ) { return this . ngControl ? this . ngControl . disabled : this . _disabled ; }
236
238
set disabled ( value : any ) { this . _disabled = coerceBooleanProperty ( value ) ; }
237
239
240
+ /** Whether the chip list is in an error state. */
238
241
get errorState ( ) : boolean {
239
242
const isInvalid = this . ngControl && this . ngControl . invalid ;
240
243
const isTouched = this . ngControl && this . ngControl . touched ;
@@ -584,22 +587,28 @@ export class MdChipList implements MdFormFieldControl<any>, ControlValueAccessor
584
587
this . _changeDetectorRef . markForCheck ( ) ;
585
588
}
586
589
590
+ /** When blurred, mark the field as touched when focus moved outside the chip list. */
587
591
_blur ( ) {
588
592
if ( ! this . disabled ) {
589
593
if ( this . _chipInput ) {
590
- // Check if focus moved to chip input. If not, do real on blur
594
+ // If there's a chip input, we should check whether the focus moved to chip input.
595
+ // If the focus is not moved to chip input, mark the field as touched. If the focus moved
596
+ // to chip input, do nothing.
597
+ // Timeout is needed to wait for the focus() event trigger on chip input.
591
598
setTimeout ( ( ) => {
592
599
if ( ! this . focused ) {
593
- this . _onBlur ( ) ;
600
+ this . _markAsTouched ( ) ;
594
601
}
595
602
} ) ;
596
603
} else {
597
- this . _onBlur ( ) ;
604
+ // If there's no chip input, then mark the field as touched.
605
+ this . _markAsTouched ( ) ;
598
606
}
599
607
}
600
608
}
601
609
602
- _onBlur ( ) {
610
+ /** Mark the field as touched */
611
+ _markAsTouched ( ) {
603
612
this . _onTouched ( ) ;
604
613
this . _changeDetectorRef . markForCheck ( ) ;
605
614
this . stateChanges . next ( ) ;
0 commit comments