-
Notifications
You must be signed in to change notification settings - Fork 331
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
"conditional.html" value on radio item has whitespace inserted into it, breaking <textarea> elements #4807
Comments
This bug is also present in v5.1.0 due to the "indent" on this line: |
Thanks for raising this @RichardBradley We should review all HTML placeholders that could contain Textarea components Textarea content in govuk-frontend/packages/govuk-frontend/src/govuk/components/textarea/template.njk Line 50 in e92f66c
I'll mention it to the team |
I wonder if the recently added/updated approach of properly indenting the emitted HTML should be reviewed entirely? While it's nice and beneficial for the |
This is still an issue when the radios/checkboxes have a fieldset. The |
@devkokov , I agree, that looks like the same bug. I don't have permission to re-open this issue. I suggest you create a new issue referencing this one if that is causing you problems. I have the fix I need for my work, so I don't plan to do any more on this. If it were up to me, I would remove all the "indent" ops from the runtime code. As I commented above, I don't see why there's any need for the runtime emitted HTML to be pretty-printed, and it can cause bugs which are very hard to detect (as well as a small runtime compute cost that is wasteful). |
I've reopened this for the time being, just in case a new issue doesn't arise. |
Description of the issue
In our public facing app, we have some radio items which conditionally reveal a text area, for users to input their overseas address, only if they answer the radio question a certain way.
(We are aware that this isn't ideal from an accessibility point of view, and we have recently been unpacking some of these into separate pages, but I don't think that invalidates this bug.)
Since v5.2.0 / commit 6955db326a2e560c9862d29b28e39bd8f4020829, whitespace is added to the html in here by govuk-frontend, which changes the value inside a textarea, corrupting user input.
Steps to reproduce the issue
Here is an extract from the njk template on our page that has caught this bug.
I have marked the key line with "HERE".
The
localisedCharacterCount
macro is our wrapper around https://design-system.service.gov.uk/components/character-count/ and contains a<textarea>
Actual vs expected behaviour
I would expect the app provided value in
conditional.html
to be emitted to the page unchanged.In fact, whitespace is added at the start of each line.
Environment (where applicable)
Other notes
I have also commented on this at #4676
It may be the case that other app-supplied param values are being indented and shouldn't be, to avoid similar issues. I haven't checked the rest of the components
The text was updated successfully, but these errors were encountered: