Skip to content

Commit 6f99852

Browse files
authored
fix(material/stepper): don't allow focus inside a hidden element (#21842)
The CSS `visibility` allows for a child element to become visible, even though its parent is hidden. This becomes a problem for an expanded stepper inside a collapsed sidenav, because it allows the user to tab into the stepper. These changes resolve the issue by transitioning to `visibility: ''` which allows it to be inherited. Fixes #21831.
1 parent e7b604f commit 6f99852

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/material/stepper/stepper-animations.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export const matStepperAnimations: {
2525
/** Animation that transitions the step along the X axis in a horizontal stepper. */
2626
horizontalStepTransition: trigger('stepTransition', [
2727
state('previous', style({transform: 'translate3d(-100%, 0, 0)', visibility: 'hidden'})),
28-
state('current', style({transform: 'none', visibility: 'visible'})),
28+
// Transition to '', rather than `visible`, because visibility on a child element overrides
29+
// the one from the parent, making this element focusable inside of a `hidden` element.
30+
state('current', style({transform: 'none', visibility: ''})),
2931
state('next', style({transform: 'translate3d(100%, 0, 0)', visibility: 'hidden'})),
3032
transition('* => *', animate('500ms cubic-bezier(0.35, 0, 0.25, 1)'))
3133
]),
@@ -34,7 +36,9 @@ export const matStepperAnimations: {
3436
verticalStepTransition: trigger('stepTransition', [
3537
state('previous', style({height: '0px', visibility: 'hidden'})),
3638
state('next', style({height: '0px', visibility: 'hidden'})),
37-
state('current', style({height: '*', visibility: 'visible'})),
39+
// Transition to '', rather than `visible`, because visibility on a child element overrides
40+
// the one from the parent, making this element focusable inside of a `hidden` element.
41+
state('current', style({height: '*', visibility: ''})),
3842
transition('* <=> current', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)'))
3943
])
4044
};

0 commit comments

Comments
 (0)