Skip to content

Commit

Permalink
fix(material/expansion): able to tab into descendants with visibility…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
crisbeto authored Mar 8, 2022
1 parent 1a03257 commit c12347c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/material/expansion/expansion-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@
display: flex;
flex-direction: column;
overflow: visible;

// Usually the `visibility: hidden` added by the animation is enough to prevent focus from
// entering the collapsed content, but children with their own `visibility` can override it.
// In other components we set a `display: none` at the root to stop focus from reaching the
// elements, however we can't do that here, because the content can determine the width
// of an expansion panel. The most practical fallback is to use `!important` to override
// any custom visibility.
&[style*='visibility: hidden'] * {
visibility: hidden !important;
}
}

.mat-expansion-panel-body {
Expand Down

1 comment on commit c12347c

@avishome
Copy link

@avishome avishome commented on c12347c Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
this is problematic solution. Since this fix I have a slowness in my app.
In the performances measuring it appear under 'recalculate style' that takes long time.
Every change to any style which affects on the parent of this component causes to recalculate styles to all the children of this component. It become to be significant when there are many expansions and items into them.
I think that you shouldn't take care of cases when the inner items visibility are visible.
thanks

Please sign in to comment.