@@ -180,11 +180,13 @@ export class MdSelectTrigger {}
180
180
'[attr.aria-invalid]' : 'errorState' ,
181
181
'[attr.aria-owns]' : '_optionIds' ,
182
182
'[attr.aria-multiselectable]' : 'multiple' ,
183
+ '[attr.aria-describedby]' : '_ariaDescribedby || null' ,
183
184
'[class.mat-select-disabled]' : 'disabled' ,
184
185
'[class.mat-select-invalid]' : 'errorState' ,
185
186
'[class.mat-select-required]' : 'required' ,
186
187
'class' : 'mat-select' ,
187
188
'(keydown)' : '_handleClosedKeydown($event)' ,
189
+ '(focus)' : '_onFocus()' ,
188
190
'(blur)' : '_onBlur()' ,
189
191
} ,
190
192
animations : [
@@ -229,6 +231,9 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
229
231
/** The cached height of the trigger element. */
230
232
private _triggerHeight : number ;
231
233
234
+ /** The aria-describedby attribute on the select for improved a11y. */
235
+ _ariaDescribedby : string ;
236
+
232
237
/** The cached font-size of the trigger element. */
233
238
_triggerFontSize = 0 ;
234
239
@@ -297,12 +302,8 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
297
302
*/
298
303
stateChanges = new Subject < void > ( ) ;
299
304
300
- /** Whether the select is focused. TODO(mmalerba): Implement for real. */
301
305
focused = false ;
302
306
303
- /** TODO(mmalerba): Implement for real. */
304
- setDescribedByIds ( x : string [ ] ) { return x }
305
-
306
307
/** Trigger that opens the select. */
307
308
@ViewChild ( 'trigger' ) trigger : ElementRef ;
308
309
@@ -329,6 +330,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
329
330
get placeholder ( ) { return this . _placeholder ; }
330
331
set placeholder ( value : string ) {
331
332
this . _placeholder = value ;
333
+ this . stateChanges . next ( ) ;
332
334
333
335
// Must wait to record the trigger width to ensure placeholder width is included.
334
336
Promise . resolve ( null ) . then ( ( ) => this . _setTriggerWidth ( ) ) ;
@@ -337,7 +339,10 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
337
339
/** Whether the component is required. */
338
340
@Input ( )
339
341
get required ( ) { return this . _required ; }
340
- set required ( value : any ) { this . _required = coerceBooleanProperty ( value ) ; }
342
+ set required ( value : any ) {
343
+ this . _required = coerceBooleanProperty ( value ) ;
344
+ this . stateChanges . next ( ) ;
345
+ }
341
346
342
347
/** Whether the user should be allowed to select multiple options. */
343
348
@Input ( )
@@ -374,6 +379,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
374
379
set value ( newValue : any ) {
375
380
this . writeValue ( newValue ) ;
376
381
this . _value = newValue ;
382
+ this . stateChanges . next ( ) ;
377
383
}
378
384
private _value : any ;
379
385
@@ -395,7 +401,10 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
395
401
/** Unique id of the element. */
396
402
@Input ( )
397
403
get id ( ) { return this . _id ; }
398
- set id ( value : string ) { this . _id = value || this . _uid ; }
404
+ set id ( value : string ) {
405
+ this . _id = value || this . _uid ;
406
+ this . stateChanges . next ( ) ;
407
+ }
399
408
private _id : string ;
400
409
401
410
/** Combined stream of all of the child options' change events. */
@@ -535,6 +544,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
535
544
setDisabledState ( isDisabled : boolean ) : void {
536
545
this . disabled = isDisabled ;
537
546
this . _changeDetectorRef . markForCheck ( ) ;
547
+ this . stateChanges . next ( ) ;
538
548
}
539
549
540
550
/** Whether or not the overlay panel is open. */
@@ -631,14 +641,23 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
631
641
this . _changeDetectorRef . markForCheck ( ) ;
632
642
}
633
643
644
+ _onFocus ( ) {
645
+ if ( ! this . disabled ) {
646
+ this . focused = true ;
647
+ this . stateChanges . next ( ) ;
648
+ }
649
+ }
650
+
634
651
/**
635
652
* Calls the touched callback only if the panel is closed. Otherwise, the trigger will
636
653
* "blur" to the panel when it opens, causing a false positive.
637
654
*/
638
655
_onBlur ( ) {
639
656
if ( ! this . disabled && ! this . panelOpen ) {
657
+ this . focused = false ;
640
658
this . _onTouched ( ) ;
641
659
this . _changeDetectorRef . markForCheck ( ) ;
660
+ this . stateChanges . next ( ) ;
642
661
}
643
662
}
644
663
@@ -1141,6 +1160,9 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
1141
1160
private _getItemCount ( ) : number {
1142
1161
return this . options . length + this . optionGroups . length ;
1143
1162
}
1163
+
1164
+ /** Sets the list of element IDs that currently describe this select. */
1165
+ setDescribedByIds ( ids : string [ ] ) { this . _ariaDescribedby = ids . join ( ' ' ) ; }
1144
1166
}
1145
1167
1146
1168
/** Clamps a value n between min and max values. */
0 commit comments