-
Notifications
You must be signed in to change notification settings - Fork 334
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
Append card title to action links inside of a Summary Card #3961
Conversation
43fbd17
to
90b03a3
Compare
packages/govuk-frontend/src/govuk/components/summary-list/template.njk
Outdated
Show resolved
Hide resolved
90b03a3
to
09cd0d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks brill from a code point of view
Do we know if this is best approach?
Versus using the <h2>
govuk-summary-card__title
with aria-describedby
?
That certainly seems like a possibility that might work in practice (assuming the AT consistently announces CC @davidc-gds in case you have a view on this. |
Hi @querkmachine from a information hierarchy standpoint, would it make sense to put the unique element (the action) first, and then the card title second? We can take the 'Summary list as a summary card with actions plus summary list actions' PR preview example as a case study. Right now it looks to be read out as:
I'm suggesting that since the unique element is the action name, we should reverse the order of the items, like so:
Thoughts , possibly from @claireashworth? |
I tested the I tested an So in conclusion:
The only consistent downside for Copy/paste using
Without using
|
@davidc-gds Swapping the order makes sense to me. The text-selection problem makes me wonder whether we want to set |
Having the action first makes sense to me as well. |
09cd0d7
to
2d8f726
Compare
I've pushed changes to place the card title after the action name. I've also added |
2d8f726
to
c086b81
Compare
@querkmachine I may be doing it wrong, but I can still copy/paste the hidden text, even with I'm using cmd + c and cmd+ v on a Mac, on Chrome. |
^ We found that David's macOS is configured is to paste with formatting by default. This doesn't appear to be the default behaviour in macOS, needing to be configured in Settings → Keyboard → Keyboard Shortcuts... → App Shortcuts. This does not happen in Firefox or Safari, so it seems to be a case of Chromium browsers purposefully ignoring the CSS rule. As this is a configuration of the user's environment, we probably can't practically do anything about it. Pasting without formatting omits the visually-hidden text as expected. Having tested in VoiceOver/Safari, NVDA/Firefox and JAWS/Chrome, it doesn't appear that making hidden text unselectable has had any side-effects to how screen readers announce or interact with it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, thanks for checking we picked the best solution 😊
Some comments on HTML output but see what you think
packages/govuk-frontend/src/govuk/components/summary-list/template.njk
Outdated
Show resolved
Hide resolved
packages/govuk-frontend/src/govuk/components/summary-list/template.njk
Outdated
Show resolved
Hide resolved
c086b81
to
b09b24d
Compare
…inks Append card title to action links inside of a Summary Card
This change appends the card title to action links when rendered within a summary card. It follows [the upstream change](alphagov/govuk-frontend#3961) introduced in govuk-frontend version 5. In the simplest case it works like the reference implementation: ```erb <%= govuk_summary_list(card: { title: "Shiny new widget" }) do |sl| %> <%= sl.with_row do |r| %> <%= r.with_key(text: "Price") %> <%= r.with_value(text: "£19.99") %> <%= r.with_action(href: "/widgets/1/edit", text: "Modify", visually_hidden_text: "this widget's price") %> <% end %> <% end %> ``` Here, the rendered HTML will now include the card title in the visually hidden text on the action: ```html <dl class="govuk-summary-list"> <div class="govuk-summary-list__row"> <dt class="govuk-summary-list__key">Price</dt> <dd class="govuk-summary-list__value">£19.99</dd> <dd class="govuk-summary-list__actions"> <a class="govuk-link" href="/a">Modify<span class="govuk-visually-hidden"> this widget's price (Shiny new widget)</span></a> </dd> </div> </dl> ``` Additionally the suffix text can be set manually. This allows it to be set without passing in `card: { ... }` when initialising the summary list. It might be useful when rendering the summary list within an outer card. It is set using the `action_suffix` keyword. ```erb <%= govuk_summary_card(title: "Shiny new widget") do %> <%= govuk_summary_list(action_suffix: "Shiny new widget") do |sl| %> <%= sl.with_row do |r| %> <%= r.with_key(text: "Price") %> <%= r.with_value(text: "£19.99") %> <%= r.with_action(href: "/widgets/1/edit", text: "Modify", visually_hidden_text: "this widget's price") %> <% end %> <% end %> <% end %> ``` This will output the same HTML as the above example. When both the `card` and `action_suffix` arguments are provided the `action_suffix` takes precedence, which offers a little more flexibility as there might be some cases other text would make more sense than the card's title. Fixes #479, #480
It was raised in the recent DAC audit that pages with multiple Summary Cards had the potential to fail the Level A criterion Link Purpose (In Context) and the Level AAA criterion Link Purpose (Link Only), due to the repetition of links with identical labels—unless the implementor went out of their way to manually provide the required distinctions.
This PR modifies the Nunjucks template for Summary Lists so that, if a card title has been provided, the title is automatically appended to any action links within the card. This is applied to both the card-level and individual row's action links.
This PR resolves #3673 add #3674.
Changes
_actionLink
macro now takes a second, optionalcardTitle
parameter._actionLink
to pass through theparams.card.title
object, if it exists.Thoughts
params.card.title.html
into a visually-hidden span feels a bit weird and like it may have adverse side effects depending on what HTML is provided, however we have no guarantee thatparams.card.title.text
is set in all situations.