Skip to content

Commit

Permalink
Prevent height change in Collapse component title (#3144)
Browse files Browse the repository at this point in the history
When toggling show/hide, if the title has a different background color than the content, and if there is lengthy content, you can see the title row/track grow during the animation before returning to its original size. Using `max-content` instead of `auto` in the grid-template-rows rule will lock the height of the title, so only the 2nd row (content) changes from `0fr` to `1fr`.
  • Loading branch information
figureone authored Dec 9, 2024
1 parent 92eacff commit f2cd7af
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/unstyled/collapse.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}
.collapse {
@apply relative grid overflow-hidden;
grid-template-rows: auto 0fr;
grid-template-rows: max-content 0fr;
transition: grid-template-rows 0.2s;
}
.collapse-title,
Expand All @@ -27,11 +27,11 @@
.collapse[open],
.collapse-open,
.collapse:focus:not(.collapse-close) {
grid-template-rows: auto 1fr;
grid-template-rows: max-content 1fr;
}
.collapse:not(.collapse-close):has(> input[type="checkbox"]:checked),
.collapse:not(.collapse-close):has(> input[type="radio"]:checked) {
grid-template-rows: auto 1fr;
grid-template-rows: max-content 1fr;
}
.collapse[open] > .collapse-content,
.collapse-open > .collapse-content,
Expand Down

0 comments on commit f2cd7af

Please sign in to comment.