Skip to content

Commit

Permalink
Merge pull request #859 from alphagov/fix-the-hovering-blue-sidebar-o…
Browse files Browse the repository at this point in the history
…n-pages-without-related-links

Avoid rendering the side content when there's no content
  • Loading branch information
fofr authored Dec 2, 2016
2 parents b62908e + 702fe78 commit c6cb0f4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 41 deletions.
77 changes: 38 additions & 39 deletions app/views/govuk_component/related_items.raw.html.erb
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
<%
sections ||= []
%>
<aside class="govuk-related-items" role="complementary">
<% sections.each do |section| %>
<h2
<% if section[:id] %>id="<%= section[:id] %>"<% end %>
>
<%= section[:title] %>
</h2>
<nav role="navigation" <% if section[:id] %>aria-labelledby="<%= section[:id] %>"<% end %>>
<ul>
<% section[:items].each do |item| %>
<li>
<a
href="<%= item[:url] %>"
<% if item[:rel] %>rel="<%= item[:rel] %>"<% end %>
>
<%= item[:title] %>
</a>
</li>
<% end %>
<% if section[:url] %>
<li class="related-items-more">
<a href="<%= section[:url] %>">
<%= t("govuk_component.related_items.more", default: "More") %>
<% if section[:title] %>
<span class="visuallyhidden">
<%= t("govuk_component.related_items.in", default: "in") %>
<%= section[:title] %>
</span>
<% end %>
</a>
</li>
<% end %>
</ul>
</nav>
<% end %>
</aside>
<% if local_assigns[:sections] && !sections.blank? %>
<aside class="govuk-related-items" role="complementary">
<% sections.each do |section| %>
<h2
<% if section[:id] %>id="<%= section[:id] %>"<% end %>
>
<%= section[:title] %>
</h2>
<nav role="navigation" <% if section[:id] %>aria-labelledby="<%= section[:id] %>"<% end %>>
<ul>
<% section[:items].each do |item| %>
<li>
<a
href="<%= item[:url] %>"
<% if item[:rel] %>rel="<%= item[:rel] %>"<% end %>
>
<%= item[:title] %>
</a>
</li>
<% end %>
<% if section[:url] %>
<li class="related-items-more">
<a href="<%= section[:url] %>">
<%= t("govuk_component.related_items.more", default: "More") %>
<% if section[:title] %>
<span class="visuallyhidden">
<%= t("govuk_component.related_items.in", default: "in") %>
<%= section[:title] %>
</span>
<% end %>
</a>
</li>
<% end %>
</ul>
</nav>
<% end %>
</aside>
<% end %>
3 changes: 1 addition & 2 deletions test/govuk_component/related_items_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ def component_name

test "no error if no parameters passed in" do
assert_nothing_raised do
render_component({})
assert_select ".govuk-related-items"
assert_empty render_component({})
end
end

Expand Down

0 comments on commit c6cb0f4

Please sign in to comment.