@@ -164,11 +164,13 @@ export class MdSelectTrigger {}
164
164
'[attr.aria-invalid]' : 'errorState' ,
165
165
'[attr.aria-owns]' : '_optionIds' ,
166
166
'[attr.aria-multiselectable]' : 'multiple' ,
167
+ '[attr.aria-describedby]' : '_ariaDescribedby || null' ,
167
168
'[class.mat-select-disabled]' : 'disabled' ,
168
169
'[class.mat-select-invalid]' : 'errorState' ,
169
170
'[class.mat-select-required]' : 'required' ,
170
171
'class' : 'mat-select' ,
171
172
'(keydown)' : '_handleClosedKeydown($event)' ,
173
+ '(focus)' : '_onFocus()' ,
172
174
'(blur)' : '_onBlur()' ,
173
175
} ,
174
176
animations : [
@@ -213,6 +215,9 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
213
215
/** The cached height of the trigger element. */
214
216
private _triggerHeight : number ;
215
217
218
+ /** The aria-describedby attribute on the select for improved a11y. */
219
+ _ariaDescribedby : string ;
220
+
216
221
/** The cached font-size of the trigger element. */
217
222
_triggerFontSize = 0 ;
218
223
@@ -281,12 +286,8 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
281
286
*/
282
287
stateChanges = new Subject < void > ( ) ;
283
288
284
- /** Whether the select is focused. TODO(mmalerba): Implement for real. */
285
289
focused = false ;
286
290
287
- /** TODO(mmalerba): Implement for real. */
288
- setDescribedByIds ( x : string [ ] ) { return x }
289
-
290
291
/** Trigger that opens the select. */
291
292
@ViewChild ( 'trigger' ) trigger : ElementRef ;
292
293
@@ -313,6 +314,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
313
314
get placeholder ( ) { return this . _placeholder ; }
314
315
set placeholder ( value : string ) {
315
316
this . _placeholder = value ;
317
+ this . stateChanges . next ( ) ;
316
318
317
319
// Must wait to record the trigger width to ensure placeholder width is included.
318
320
Promise . resolve ( null ) . then ( ( ) => this . _setTriggerWidth ( ) ) ;
@@ -321,7 +323,10 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
321
323
/** Whether the component is required. */
322
324
@Input ( )
323
325
get required ( ) { return this . _required ; }
324
- set required ( value : any ) { this . _required = coerceBooleanProperty ( value ) ; }
326
+ set required ( value : any ) {
327
+ this . _required = coerceBooleanProperty ( value ) ;
328
+ this . stateChanges . next ( ) ;
329
+ }
325
330
326
331
/** Whether the user should be allowed to select multiple options. */
327
332
@Input ( )
@@ -349,6 +354,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
349
354
set value ( newValue : any ) {
350
355
this . writeValue ( newValue ) ;
351
356
this . _value = newValue ;
357
+ this . stateChanges . next ( ) ;
352
358
}
353
359
private _value : any ;
354
360
@@ -370,7 +376,10 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
370
376
/** Unique id of the element. */
371
377
@Input ( )
372
378
get id ( ) { return this . _id ; }
373
- set id ( value : string ) { this . _id = value || this . _uid ; }
379
+ set id ( value : string ) {
380
+ this . _id = value || this . _uid ;
381
+ this . stateChanges . next ( ) ;
382
+ }
374
383
private _id : string ;
375
384
376
385
/** Combined stream of all of the child options' change events. */
@@ -521,6 +530,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
521
530
setDisabledState ( isDisabled : boolean ) : void {
522
531
this . disabled = isDisabled ;
523
532
this . _changeDetectorRef . markForCheck ( ) ;
533
+ this . stateChanges . next ( ) ;
524
534
}
525
535
526
536
/** Whether or not the overlay panel is open. */
@@ -613,14 +623,23 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
613
623
this . _changeDetectorRef . markForCheck ( ) ;
614
624
}
615
625
626
+ _onFocus ( ) {
627
+ if ( ! this . disabled ) {
628
+ this . focused = true ;
629
+ this . stateChanges . next ( ) ;
630
+ }
631
+ }
632
+
616
633
/**
617
634
* Calls the touched callback only if the panel is closed. Otherwise, the trigger will
618
635
* "blur" to the panel when it opens, causing a false positive.
619
636
*/
620
637
_onBlur ( ) {
621
638
if ( ! this . disabled && ! this . panelOpen ) {
639
+ this . focused = false ;
622
640
this . _onTouched ( ) ;
623
641
this . _changeDetectorRef . markForCheck ( ) ;
642
+ this . stateChanges . next ( ) ;
624
643
}
625
644
}
626
645
@@ -1131,6 +1150,8 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
1131
1150
return 0 ;
1132
1151
}
1133
1152
1153
+ /** Sets the list of element IDs that currently describe this select. */
1154
+ setDescribedByIds ( ids : string [ ] ) { this . _ariaDescribedby = ids . join ( ' ' ) ; }
1134
1155
}
1135
1156
1136
1157
/** Clamps a value n between min and max values. */
0 commit comments