Skip to content

Commit

Permalink
Hide accordion content during js-enabled page load
Browse files Browse the repository at this point in the history
Restores previous behaviour to avoid a visual layout shift as accordions jump from open to closed
  • Loading branch information
colinrotherham committed Dec 12, 2022
1 parent 84e7049 commit 60f87a2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/govuk/components/accordion/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,18 @@
padding-top: 0;
}

// Hide the body of collapsed sections by default for browsers that lack
// support for `content-visibility` paired with [hidden=until-found]
.govuk-accordion__section-content {
display: none;

@include govuk-responsive-padding(3, "top");
@include govuk-responsive-padding(8, "bottom");
}

// Manually apply display: none to browsers that don't have a user agent
// style for it, but override it with content-visibility if the browser
// supports that instead.
// Hide the body of collapsed sections using `content-visibility` to enable
// page search within [hidden=until-found] regions where browser supported
.govuk-accordion__section-content[hidden] {
display: none;

@supports (content-visibility: hidden) {
content-visibility: hidden;
display: inherit;
Expand All @@ -67,6 +68,11 @@
padding-bottom: 0;
}

// Show the body of expanded sections
.govuk-accordion__section--expanded .govuk-accordion__section-content {
display: block;
}

.govuk-accordion__show-all {
@include govuk-font($size: 19);
position: relative;
Expand Down

0 comments on commit 60f87a2

Please sign in to comment.