Avoid rendenring an empty list in top links
We've had an accessibility error reported by the Spanish "Portal Administración electrónica" (PAe). While I can't find any accessibility rule saying empty lists should be avoided, it looks like some screen readers report finding lists with 0 items, which is annoying.
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
<ul class="no-bullet external-links">
|
<ul class="no-bullet external-links">
|
||||||
<%= raw content_block("top_links", I18n.locale) %>
|
<%= raw top_links_content_block %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
class Layout::TopLinksComponent < ApplicationComponent
|
class Layout::TopLinksComponent < ApplicationComponent
|
||||||
delegate :content_block, to: :helpers
|
delegate :content_block, to: :helpers
|
||||||
|
|
||||||
|
def render?
|
||||||
|
top_links_content_block.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def top_links_content_block
|
||||||
|
content_block("top_links", I18n.locale)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
19
spec/components/layout/top_links_component_spec.rb
Normal file
19
spec/components/layout/top_links_component_spec.rb
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
require "rails_helper"
|
||||||
|
|
||||||
|
describe Layout::TopLinksComponent, type: :component do
|
||||||
|
describe "#render?" do
|
||||||
|
it "renders when a content block is defined" do
|
||||||
|
create(:site_customization_content_block, name: "top_links")
|
||||||
|
|
||||||
|
render_inline Layout::TopLinksComponent.new
|
||||||
|
|
||||||
|
expect(page).to have_css "ul"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does not render when no content block is defined" do
|
||||||
|
render_inline Layout::TopLinksComponent.new
|
||||||
|
|
||||||
|
expect(page).not_to have_css "ul"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user