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

Remove indents from conditional reveals in radios and checkboxes #4899

Merged
merged 1 commit into from
Apr 4, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ We've made fixes to GOV.UK Frontend in the following pull requests:

- [#4906: Update the icon in the warning text component to match the defined text colour and background colour, rather than always being white on black](https://github.com/alphagov/govuk-frontend/pull/4906)
- [#4919: Use canvas colour for cookie banner over hardcoded grey](https://github.com/alphagov/govuk-frontend/pull/4919)
- [#4899: Remove indents from conditional reveals in radios and checkboxes](https://github.com/alphagov/govuk-frontend/pull/4899)

## GOV.UK Frontend v5.3.0 (Feature release)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -955,3 +955,16 @@ examples:
- value: blue
text: Blue
values: [red, green]
- name: textarea in conditional
hidden: true
options:
name: conditional
items:
- value: other
text: Other
conditional:
html: |
<label class="govuk-label" for="conditional-textarea">textarea</label>
<textarea class="govuk-textarea govuk-!-width-one-third" name="conditional-textarea" id="conditional-textarea">
test
</textarea>
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</div>
{% if item.conditional.html %}
<div class="govuk-checkboxes__conditional {%- if not isChecked %} govuk-checkboxes__conditional--hidden{% endif %}" id="{{ conditionalId }}">
{{ item.conditional.html | safe | trim | indent(6) }}
{{ item.conditional.html | safe | trim }}
</div>
{% endif %}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,15 @@ describe('Checkboxes', () => {
const $input = $('.govuk-checkboxes__input').first()
expect($input.attr('data-aria-controls')).toBeFalsy()
})

// Indentation in nunjucks can mutate the value of textareas, since
// textarea value is defined between the html tags
it('does not add space to the input value of textareas inside conditionals', () => {
const $ = render('checkboxes', examples['textarea in conditional'])

const $textarea = $('#conditional-textarea')
expect($textarea.text()).toBe('test\n')
})
})

describe('when they include an error message', () => {
Expand Down
13 changes: 13 additions & 0 deletions packages/govuk-frontend/src/govuk/components/radios/radios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -944,3 +944,16 @@ examples:
- value: blue
text: Blue
value: green
- name: textarea in conditional
hidden: true
options:
name: conditional
items:
- value: other
text: Other
conditional:
html: |
<label class="govuk-label" for="conditional-textarea">textarea</label>
<textarea class="govuk-textarea govuk-!-width-one-third" name="conditional-textarea" id="conditional-textarea">
test
</textarea>
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</div>
{% if item.conditional.html %}
<div class="govuk-radios__conditional {%- if not isChecked %} govuk-radios__conditional--hidden{% endif %}" id="{{ conditionalId }}">
{{ item.conditional.html | safe | trim | indent(6) }}
{{ item.conditional.html | safe | trim }}
</div>
{% endif %}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,15 @@ describe('Radios', () => {
const $input = $('.govuk-radios__input').first()
expect($input.attr('data-aria-controls')).toBeFalsy()
})

// Indentation in nunjucks can mutate the value of textareas, since
// textarea value is defined between the html tags
it('does not add space to the input value of textareas inside conditionals', () => {
const $ = render('radios', examples['textarea in conditional'])

const $textarea = $('#conditional-textarea')
expect($textarea.text()).toBe('test\n')
})
})

it('render divider', () => {
Expand Down