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>
5353 aria-label ="Inverted vertical slider ">
5454</ mat-slider >
5555
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+
5661< mat-tab-group >
5762 < mat-tab label ="One ">
5863 < 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
267267 return this . value || 0 ;
268268 }
269269
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+
270280 /** onTouch function registered via registerOnTouch (ControlValueAccessor). */
271281 onTouched : ( ) => any = ( ) => { } ;
272282
@@ -691,6 +701,11 @@ export class MatSlider extends _MatSliderMixinBase
691701 this . _elementRef . nativeElement . focus ( ) ;
692702 }
693703
704+ /** Blurs the native element. */
705+ private _blurHostElement ( ) {
706+ this . _elementRef . nativeElement . blur ( ) ;
707+ }
708+
694709 /**
695710 * Sets the model value. Implemented as part of ControlValueAccessor.
696711 * @param value
You can’t perform that action at this time.
0 commit comments