File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,11 @@ <h1>Inverted vertical slider</h1>
53
53
aria-label ="Inverted vertical slider ">
54
54
</ mat-slider >
55
55
56
+ < h1 > Set/lost focus to show thumblabel programmatically</ h1 >
57
+ < mat-slider #demoSlider ="matSlider " thumbLabel aria-label ="Slider with thumb label "> </ mat-slider >
58
+ < button (click) ="demoSlider.focus() "> Focus Slider</ button >
59
+ < button (click) ="demoSlider.blur() "> Blur Slider</ button >
60
+
56
61
< mat-tab-group >
57
62
< mat-tab label ="One ">
58
63
< mat-slider min ="1 " max ="5 " value ="3 " aria-label ="Slider in a tab "> </ mat-slider >
Original file line number Diff line number Diff line change @@ -267,6 +267,16 @@ export class MatSlider extends _MatSliderMixinBase
267
267
return this . value || 0 ;
268
268
}
269
269
270
+ /** set focus to the host element */
271
+ focus ( ) {
272
+ this . _focusHostElement ( ) ;
273
+ }
274
+
275
+ /** blur the host element */
276
+ blur ( ) {
277
+ this . _blurHostElement ( ) ;
278
+ }
279
+
270
280
/** onTouch function registered via registerOnTouch (ControlValueAccessor). */
271
281
onTouched : ( ) => any = ( ) => { } ;
272
282
@@ -691,6 +701,11 @@ export class MatSlider extends _MatSliderMixinBase
691
701
this . _elementRef . nativeElement . focus ( ) ;
692
702
}
693
703
704
+ /** Blurs the native element. */
705
+ private _blurHostElement ( ) {
706
+ this . _elementRef . nativeElement . blur ( ) ;
707
+ }
708
+
694
709
/**
695
710
* Sets the model value. Implemented as part of ControlValueAccessor.
696
711
* @param value
You can’t perform that action at this time.
0 commit comments