Skip to content

Commit

Permalink
Change paragraph to div for descriptions to support govspeak
Browse files Browse the repository at this point in the history
  • Loading branch information
Dilwoar Hussain committed Jul 12, 2019
1 parent b39d6ec commit c93bce2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased changes

* Change paragraph to div for descriptions to support govspeak (PR #985)

## 17.13.0

* Add support for description text (PR #971)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<%= cb_helper.heading_markup %>

<% if cb_helper.description %>
<%= tag.p cb_helper.description, class: "govuk-body" %>
<%= tag.div cb_helper.description, class: "govuk-body" %>
<% end %>

<% if cb_helper.hint_text %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<% end %>

<% if description.present? %>
<%= tag.p description, class: "govuk-body" %>
<%= tag.div description, class: "govuk-body" %>
<% end %>

<% if hint %>
Expand Down
14 changes: 14 additions & 0 deletions spec/components/checkboxes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,18 @@ def component_name
)
assert_select ".govuk-body", text: "This is a description about skittles."
end

it "renders checkboxes with a govspeak description text" do
render_component(
name: "favourite_colour",
heading: "What is your favourite skittle?",
description: render("govuk_publishing_components/components/govspeak",
content: "<p>This is a description about skittles.</p>".html_safe),
items: [
{ label: "Red", value: "red" },
{ label: "Green", value: "green" },
]
)
assert_select ".govuk-body", text: "This is a description about skittles."
end
end
14 changes: 14 additions & 0 deletions spec/components/radio_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,20 @@ def component_name
)
assert_select ".govuk-body", "This is a description about skittles."
end

it "renders govspeak description text" do
render_component(
name: "favourite-skittle",
heading: "What is your favourite skittle?",
description: render("govuk_publishing_components/components/govspeak",
content: "<p>This is a description about skittles.</p>".html_safe),
items: [
{ label: "Red", value: "red" },
{ label: "Blue", value: "blue" }
]
)
assert_select ".govuk-body", "This is a description about skittles."
end
end

# This component can be interacted with, so use integration tests for these cases.
Expand Down

0 comments on commit c93bce2

Please sign in to comment.