Skip to content

Commit

Permalink
Switch hint from span to div
Browse files Browse the repository at this point in the history
It's possible to pass HTML into the hint component, but this becomes invalid HTML if someone passes a block element in (for example: a <p> tag) as the hint wraps everything in a span.

This commit switches the hint from using a wrapping span to a div, so block elements can be passed in as valid HTML.
  • Loading branch information
Vanita Barrett committed Jul 8, 2020
1 parent 7680cb3 commit d92d3c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/govuk/components/hint/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// is unlikely that the default or govuk-label--s class would be used in this
// case.

// This adjustment will not work in browsers that do not support :not().
// This adjustment will not work in browsers that do not support :not().
// Users with these browsers will see the default size margin (5px larger).

.govuk-label:not(.govuk-label--m):not(.govuk-label--l):not(.govuk-label--xl) + .govuk-hint {
Expand All @@ -30,7 +30,7 @@
// it is unlikely that the default or govuk-fieldset__legend--s class would be
// used in this case.

// This adjustment will not work in browsers that do not support :not().
// This adjustment will not work in browsers that do not support :not().
// Users with these browsers will see the default size margin (5px larger).

.govuk-fieldset__legend:not(.govuk-fieldset__legend--m):not(.govuk-fieldset__legend--l):not(.govuk-fieldset__legend--xl) + .govuk-hint {
Expand Down
4 changes: 2 additions & 2 deletions src/govuk/components/hint/template.njk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<span {%- if params.id %} id="{{ params.id }}"{% endif %} class="govuk-hint {%- if params.classes %} {{ params.classes }}{% endif %}"
<div {%- if params.id %} id="{{ params.id }}"{% endif %} class="govuk-hint {%- if params.classes %} {{ params.classes }}{% endif %}"
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}>
{{ params.html | safe if params.html else params.text }}
</span>
</div>

0 comments on commit d92d3c8

Please sign in to comment.