Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace global js-hidden class with tabs panel modifier #916

Merged
merged 2 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@

🔧 Fixes:

- Pull Request Title goes here

Description goes here (optional)

([PR #N](https://github.com/alphagov/govuk-frontend/pull/N))
- Replace conflicting `js-hidden` class used within the tabs component with a new modifier class.
Because this class is defined and used within the JavaScript, no markup changes are required.
([PR #916](https://github.com/alphagov/govuk-frontend/pull/916))


## 1.1.1 (fix release)
Expand Down
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
10 changes: 5 additions & 5 deletions src/components/tabs/tabs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ describe('/components/tabs', () => {
it('should display the first tab panel', async () => {
await page.goto(baseUrl + '/components/tabs/preview', { waitUntil: 'load' })

const tabPanelIsHidden = await page.evaluate(() => document.body.querySelector('.govuk-tabs > .govuk-tabs__panel').classList.contains('js-hidden'))
const tabPanelIsHidden = await page.evaluate(() => document.body.querySelector('.govuk-tabs > .govuk-tabs__panel').classList.contains('govuk-tabs__panel--hidden'))
expect(tabPanelIsHidden).toBeFalsy()
})

it('should hide all the tab panels except for the first one', async () => {
await page.goto(baseUrl + '/components/tabs/preview', { waitUntil: 'load' })

const tabPanelIsHidden = await page.evaluate(() => document.body.querySelector('.govuk-tabs > .govuk-tabs__panel ~ .govuk-tabs__panel').classList.contains('js-hidden'))
const tabPanelIsHidden = await page.evaluate(() => document.body.querySelector('.govuk-tabs > .govuk-tabs__panel ~ .govuk-tabs__panel').classList.contains('govuk-tabs__panel--hidden'))
expect(tabPanelIsHidden).toBeTruthy()
})
})
Expand All @@ -78,7 +78,7 @@ describe('/components/tabs', () => {

const secondTabPanelIsHidden = await page.evaluate(() => {
const secondTabAriaControls = document.body.querySelector('.govuk-tabs__list-item:nth-child(2) .govuk-tabs__tab').getAttribute('aria-controls')
return document.body.querySelector(`[id="${secondTabAriaControls}"]`).classList.contains('js-hidden')
return document.body.querySelector(`[id="${secondTabAriaControls}"]`).classList.contains('govuk-tabs__panel--hidden')
})
expect(secondTabPanelIsHidden).toBeFalsy()
})
Expand All @@ -105,7 +105,7 @@ describe('/components/tabs', () => {

const secondTabPanelIsHidden = await page.evaluate(() => {
const secondTabAriaControls = document.body.querySelector('.govuk-tabs__list-item:nth-child(2) .govuk-tabs__tab').getAttribute('aria-controls')
return document.body.querySelector(`[id="${secondTabAriaControls}"]`).classList.contains('js-hidden')
return document.body.querySelector(`[id="${secondTabAriaControls}"]`).classList.contains('govuk-tabs__panel--hidden')
})
expect(secondTabPanelIsHidden).toBeFalsy()
})
Expand All @@ -118,7 +118,7 @@ describe('/components/tabs', () => {
const currentTabAriaSelected = await page.evaluate(() => document.body.querySelector('.govuk-tabs__tab[href="#past-week"]').getAttribute('aria-selected'))
expect(currentTabAriaSelected).toEqual('true')

const currentTabPanelIsHidden = await page.evaluate(() => document.getElementById('past-week').classList.contains('js-hidden'))
const currentTabPanelIsHidden = await page.evaluate(() => document.getElementById('past-week').classList.contains('govuk-tabs__panel--hidden'))
expect(currentTabPanelIsHidden).toBeFalsy()
})
})
Expand Down