Skip to content

Commit c12347c

Browse files
authored
fix(material/expansion): able to tab into descendants with visibility while closed (#24045)
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 1a03257 commit c12347c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/material/expansion/expansion-panel.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@
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+
// In other components we set a `display: none` at the root to stop focus from reaching the
55+
// elements, however we can't do that here, because the content can determine the width
56+
// of an expansion panel. The most practical fallback is to use `!important` to override
57+
// any custom visibility.
58+
&[style*='visibility: hidden'] * {
59+
visibility: hidden !important;
60+
}
5161
}
5262

5363
.mat-expansion-panel-body {

0 commit comments

Comments
 (0)