From 9a32d85ce1d6f491ebf611fc296d75d371a507df Mon Sep 17 00:00:00 2001 From: dnoneill Date: Fri, 6 Dec 2024 17:46:59 -0500 Subject: [PATCH] add aria-current for view-type buttons --- .../blacklight/response/view_type_button_component.html.erb | 2 +- .../blacklight/response/view_type_button_component.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/components/blacklight/response/view_type_button_component.html.erb b/app/components/blacklight/response/view_type_button_component.html.erb index b5ef58d0ff..8696d8de2c 100644 --- a/app/components/blacklight/response/view_type_button_component.html.erb +++ b/app/components/blacklight/response/view_type_button_component.html.erb @@ -1,4 +1,4 @@ -<%= link_to url, title: label, class: "#{Array(@classes).join(' ')} view-type-#{ @key.to_s.parameterize } #{"active" if selected?}" do %> +<%= link_to url, title: label, aria: aria_attributes, class: "#{Array(@classes).join(' ')} view-type-#{ @key.to_s.parameterize } #{"active" if selected?}" do %> <%= icon %> <%= label %> <% end %> diff --git a/app/components/blacklight/response/view_type_button_component.rb b/app/components/blacklight/response/view_type_button_component.rb index 3ec0474537..5bd2fde2ac 100644 --- a/app/components/blacklight/response/view_type_button_component.rb +++ b/app/components/blacklight/response/view_type_button_component.rb @@ -25,6 +25,12 @@ def label @view.display_label end + def aria_attributes + return unless selected? + + { current: true } + end + def url helpers.url_for(@search_state.to_h.merge(view: @key)) end