Closed RichardBradley closed 6 months ago
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 params.value
was left unformatted here for the same reason:
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 govuk-frontend
source code files themselves to be nicely indented at coding-time, is there really any justification for the templating framework to be re-indenting things at runtime? There will be a small but significant runtime cost of the compute resources spent by millions and millions of web requests to reformat HTML to essentially zero benefit.
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 https://github.com/alphagov/govuk-frontend/pull/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