Skip to content

Commit

Permalink
Replace global js-hidden class with tabs panel modifier
Browse files Browse the repository at this point in the history
`js-hidden` is a global class that is defined by GOV.UK Template (https://github.com/alphagov/govuk_template/blob/78cbc105b564d2f4a83bb257abb98322bb851a93/source/assets/stylesheets/_accessibility.scss#L17)

This could mean that if users include GOV.UK Frontend into their project it could break the JavaScript fallback
in their project, since the tabs' implementation of `js-hidden` does not check for the presense of the
`js-enabled` class.

To avoid this problem we avoid a global class name and instead create a modifier for the panel component which is being hidden.
  • Loading branch information
NickColley committed Jul 17, 2018
1 parent 7c3f0a2 commit 6302294
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/components/tabs/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@
border: 1px solid $govuk-border-colour;
border-top: 0;

&--hidden {
display: none;
}

& > :last-child {
margin-bottom: 0;
}
}
}

}

.js-hidden {
display: none;
}
}
2 changes: 1 addition & 1 deletion src/components/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function Tabs ($module) {
this.$tabs = $module.querySelectorAll('.govuk-tabs__tab')

this.keys = { left: 37, right: 39, up: 38, down: 40 }
this.jsHiddenClass = 'js-hidden'
this.jsHiddenClass = 'govuk-tabs__panel--hidden'
}

Tabs.prototype.init = function () {
Expand Down

0 comments on commit 6302294

Please sign in to comment.