Skip to content

Commit

Permalink
Hide Accordion content (again) during .js-enabled page load
Browse files Browse the repository at this point in the history
When loading the Accordion component with JavaScript enabled, this change restores `display: none` on section content

For context, we switched to `display: inherit` previously:
#3053

But for slow-loading pages we saw a visual layout shift as each section flickered closed (from open) after initialisation

We’d like to take another look at how components load in:
#999
  • Loading branch information
colinrotherham committed Dec 13, 2022
1 parent 9e7d19d commit ff364ed
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 ff364ed

Please sign in to comment.