Skip to content

Commit

Permalink
Merge pull request #707 from alphagov/panel-dont-render-empty-div
Browse files Browse the repository at this point in the history
Fix body element rendering with no text
  • Loading branch information
NickColley authored May 22, 2018
2 parents e252d0c + a51af37 commit 914b00f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Fixes:
- Update component readme files content
([PR #704](https://github.com/alphagov/govuk-frontend/pull/704))

- Fix body element rendering with no text
([PR #707](https://github.com/alphagov/govuk-frontend/pull/707))

New features:

- Add override classes to set `display` property to `block`, `inline` and `inline-block` (PR [#694](https://github.com/alphagov/govuk-frontend/pull/654))
Expand Down
2 changes: 2 additions & 0 deletions src/components/panel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ Find out when to use the Panel component in your service in the [GOV.UK Design S
<h2 class="govuk-panel__title">
Application complete
</h2>

<div class="govuk-panel__body">
Your reference number: HDJ2123F
</div>

</div>

#### Macro
Expand Down
2 changes: 2 additions & 0 deletions src/components/panel/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<h2 class="govuk-panel__title">
{{ params.titleHtml | safe if params.titleHtml else params.titleText }}
</h2>
{% if params.html or params.text %}
<div class="govuk-panel__body">
{{ params.html | safe if params.html else params.text }}
</div>
{% endif %}
</div>
9 changes: 9 additions & 0 deletions src/components/panel/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,13 @@ describe('Panel', () => {
expect($component.attr('first-attribute')).toEqual('true')
expect($component.attr('second-attribute')).toEqual('false')
})

it('doesnt render panel body if no body text is passed', () => {
const $ = render('panel', {
titleText: 'Application complete'
})
const panelBody = $('.govuk-panel__body').length

expect(panelBody).toBeFalsy()
})
})

0 comments on commit 914b00f

Please sign in to comment.