Skip to content

Commit

Permalink
Fix duplicate IDs issue in component guide
Browse files Browse the repository at this point in the history
- adding a random string to the generated ID of toggle elements means accessibility warnings don't get triggered in the component guide anymore
  • Loading branch information
andysellick committed Nov 22, 2018
1 parent f4de2c2 commit 93a2143
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
<% if from.any? %>
<dt class="gem-c-metadata__term"><%= t("govuk_component.metadata.from", default: "From") %>:</dt>
<dd class="gem-c-metadata__definition">
<%= render 'govuk_publishing_components/components/metadata/sentence', items: from, toggle_id: "from" %>
<%= render 'govuk_publishing_components/components/metadata/sentence', items: from, toggle_id: "from-#{SecureRandom.hex(4)}" %>
</dd>
<% end %>
<% if part_of.any? %>
<dt class="gem-c-metadata__term"><%= t("govuk_component.metadata.part_of", default: "Part of") %>:</dt>
<dd class="gem-c-metadata__definition">
<%= render 'govuk_publishing_components/components/metadata/sentence', items: part_of, toggle_id: "part-of" %>
<%= render 'govuk_publishing_components/components/metadata/sentence', items: part_of, toggle_id: "part-of-#{SecureRandom.hex(4)}" %>
</dd>
<% end %>
<% if local_assigns.include?(:history) %>
Expand Down Expand Up @@ -59,7 +59,7 @@
<% if definition.any? %>
<dt class="gem-c-metadata__term"><%= title %>:</dt>
<dd class="gem-c-metadata__definition">
<%= render 'govuk_publishing_components/components/metadata/sentence', items: definition, toggle_id: index %>
<%= render 'govuk_publishing_components/components/metadata/sentence', items: definition, toggle_id: "#{index}-#{SecureRandom.hex(4)}" %>
</dd>
<% end %>
<% end %>
Expand Down

0 comments on commit 93a2143

Please sign in to comment.