File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { FocusMonitor } from '@angular/cdk/a11y' ;
9
+ import { FocusMonitor , FocusOrigin } from '@angular/cdk/a11y' ;
10
10
import {
11
11
ChangeDetectionStrategy ,
12
12
ChangeDetectorRef ,
@@ -99,8 +99,12 @@ export class MatStepHeader extends _MatStepHeaderMixinBase implements AfterViewI
99
99
}
100
100
101
101
/** Focuses the step header. */
102
- focus ( ) {
103
- this . _focusMonitor . focusVia ( this . _elementRef , 'program' ) ;
102
+ focus ( origin ?: FocusOrigin ) {
103
+ if ( origin ) {
104
+ this . _focusMonitor . focusVia ( this . _elementRef , origin ) ;
105
+ } else {
106
+ this . _elementRef . nativeElement . focus ( ) ;
107
+ }
104
108
}
105
109
106
110
/** Returns string label of given step if it is a text label. */
Original file line number Diff line number Diff line change @@ -881,6 +881,19 @@ describe('MatStepper', () => {
881
881
expect ( headerRipples . every ( ripple => ripple . disabled ) ) . toBe ( true ) ;
882
882
} ) ;
883
883
884
+ it ( 'should be able to disable ripples' , ( ) => {
885
+ const fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
886
+ fixture . detectChanges ( ) ;
887
+
888
+ const stepHeaders = fixture . debugElement . queryAll ( By . directive ( MatStepHeader ) ) ;
889
+
890
+ stepHeaders [ 0 ] . componentInstance . focus ( 'mouse' ) ;
891
+ stepHeaders [ 1 ] . componentInstance . focus ( ) ;
892
+
893
+ expect ( stepHeaders [ 1 ] . nativeElement . classList ) . toContain ( 'cdk-focused' ) ;
894
+ expect ( stepHeaders [ 1 ] . nativeElement . classList ) . toContain ( 'cdk-mouse-focused' ) ;
895
+ } ) ;
896
+
884
897
it ( 'should be able to set the theme for all steps' , ( ) => {
885
898
const fixture = createComponent ( SimpleMatVerticalStepperApp ) ;
886
899
fixture . detectChanges ( ) ;
You can’t perform that action at this time.
0 commit comments