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

Can't apply ids to row keys, values and anchor links on summary list component #866

Open
adeel718 opened this issue Mar 31, 2023 · 1 comment

Comments

@adeel718
Copy link

Bug Report

On the summary list component it is currently not possible to add ids to rows.keys, rows.values or the action item hrefs.

What is the issue?

There should be the ability to add ids

What steps are required to reproduce the issue?

Create a summary list component

Is there anything else you think would be useful in recreating the issue?

image

@GWRowley
Copy link

GWRowley commented Mar 31, 2023

Suggested fix for actions in components/summary-list/template.njk lines 1-8

{%- macro _link(action) %}
  <a href="{{ action.href }}" {%- if action.classes %} class="{{ action.classes }}"{% endif %} {%- if action.id %} id="{{ action.id }}"{% endif %}>
    {{ action.html | safe if action.html else action.text }}
    {%- if action.visuallyHiddenText -%}
    <span class="nhsuk-u-visually-hidden"> {{ action.visuallyHiddenText }}</span>
    {% endif -%}
  </a>
{% endmacro -%}

Suggested fix for adding IDs to key and value in components/summary-list/template.njk lines 12-17

<dt class="nhsuk-summary-list__key {%- if row.key.classes %} {{ row.key.classes }}{% endif %}" {% for attribute, value in row.key.attributes %} {{attribute}}="{{value}}"{% endfor %}>
   {{ row.key.html | safe if row.key.html else row.key.text }}
</dt>
<dd class="nhsuk-summary-list__value {%- if row.value.classes %} {{ row.value.classes }}{% endif %}" {% for attribute, value in row.value.attributes %} {{attribute}}="{{value}}"{% endfor %}>
   {{ row.value.html | indent(8) | trim | safe if row.value.html else row.value.text }}
</dd>

Then in your nunjucks file you can use something like:

key: {
  text: "Starts on",
  attributes: {
    id: "starts-on-key"
  }
}

Whilst maintaining flexibility to add other attributes not just ID if ever necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants