Skip to content

Commit d7afb2b

Browse files
committed
fix(material/expansion): able to tab into descendants with visibility while closed
The expansion panel sets `visibility: hidden` while it's closed in order to prevent users from tabbing into the content. This breaks down if a child has its own `visibility`, because it overrides the one coming from the parent. We can't use `display` in the animation definition, because it prevents the animations module from calculating the height when animating. These changes add some CSS that will set `display: none` once the animation has settled.
1 parent 8ae41b0 commit d7afb2b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/material/expansion/expansion-panel.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@
4848
display: flex;
4949
flex-direction: column;
5050
overflow: visible;
51+
52+
// Usually the `visibility: hidden` added by the animation is enough to prevent focus from
53+
// entering the collapsed content, but children with their own `visibility` can override it.
54+
// This is a fallback that completely hides the content when the element becomes hidden.
55+
// Note that we can't do this in the animation definition, because the style gets recomputed too
56+
// late, breaking the animation because Angular didn't have time to figure out the target height.
57+
// This can also be achieved with JS, but it has issues when when starting an animation before
58+
// the previous one has finished.
59+
&[style*='visibility: hidden'] {
60+
display: none;
61+
}
5162
}
5263

5364
.mat-expansion-panel-body {

0 commit comments

Comments
 (0)