thoughtbot/croutons

aria-current

Closed this issue · 1 comments

I’m not sure I fully understand what is output using this gem, but I wonder if outputting aria-current="location" would make sense? It improves accessibility by denoting where a user current is, to assistive technology:

<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/">Contact us</a></li>
    <li><a href="/" aria-current="location">Phone numbers</a></li>
  </ul>
</nav>

Good call.

The most obvious way of doing this would be to modify app/views/breadcrumbs/_breadcrumbs.html.erb with something like:

<% if current_page?(breadcrumb.url) %>
  <li><%= link_to breadcrumb.label, breadcrumb.url, "aria-current" => "location" %></li>
<% else %>
  <li><%= link_to breadcrumb.label, breadcrumb.url %></li>
<% end %>

There's a lot of repetition in there though, so we might also want to extract some kind of helper.