Skip to content

Textarea inside a tabs component mutates a multiline value #100

@samuelhwilliams

Description

@samuelhwilliams

Describe the bug
When one of the items passed into a tabs component is a textarea, with a value that has a multiline string, the textarea input gets indented.

https://github.com/LandRegistry/govuk-frontend-jinja/blob/main/govuk_frontend_jinja/templates/components/tabs/macro.html#L45
https://github.com/LandRegistry/govuk-frontend-jinja/blob/main/govuk_frontend_jinja/templates/components/tabs/macro.html#L19

It is seemingly not safe to use indent() on textareas, because it can change the value passed in.

To Reproduce
Steps to reproduce the behavior:

  1. Setup a wtform with a stringfield using a govuktextarea widget.
  2. Instantiate the form and pass some multiline text data to the field
  3. Render the textarea using govukTextarea inside a govukTabs component.
  4. See that lines 2+ are prefixed with 4 spaces.

Expected behavior
The value of the textarea is not changed by rendering it inside a tabs component.

Screenshots

With native govuk-frontend-jinja macro

Image

With modified govuk-frontend-jinja macro (all indent() calls removed)

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions