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

Add id to summary action links #3513

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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 src/components/summary/_macro-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

| Name | Type | Required | Description |
| ---------------------- | ---------------------- | -------- | ------------------------------------------------------------------------------------------- |
| id | string | false | `id` of the action links |
| iconType | string | false | Adds an icon before the row title, by setting the [icon type](/foundations/icons#icon-type) |
| iconVisuallyHiddenText | string | false | Visually hidden text in a span under the icon to add more context for screen readers |
| title | string | false | The title for the row item |
Expand Down
2 changes: 1 addition & 1 deletion src/components/summary/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
</dd>
{% endif %}
{% if item.actions %}
<dd class="ons-summary__actions">
<dd class="ons-summary__actions" {% if item.id %}id="{{ item.id }}"{% endif %}>
{% for action in item.actions %}
{% if loop.index > 1 %}<span class="ons-summary__spacer"></span>{% endif %}
<a
Expand Down
6 changes: 6 additions & 0 deletions src/components/summary/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,12 @@ describe('macro: summary', () => {
).toBe('Action 2');
});

it('has the correct `id` added to the actions', () => {
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));

expect($('.ons-summary__items .ons-summary__item:nth-of-type(2) .ons-summary__actions').attr('id')).toBe('item-id-2');
});

it('has the correct visually hidden <span> text', () => {
const $ = cheerio.load(renderComponent('summary', EXAMPLE_SUMMARY_BASIC));

Expand Down