Skip to content

Commit

Permalink
[#3518] Remove incomplete implementation of menu aria role from Black…
Browse files Browse the repository at this point in the history
…light::System::DropdownComponent

Closes #3518
  • Loading branch information
sandbergja committed Mar 6, 2025
1 parent 3620b34 commit bd1b73e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= content_tag :div, id: @id, class: @classes.join(' ') do %>
<%= button %>

<div class="dropdown-menu" role="menu">
<div class="dropdown-menu">
<% options.each do |option| %>
<%= option %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/components/blacklight/system/dropdown_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DropdownComponent < Blacklight::Component
renders_one :button, DropdownButtonComponent

renders_many :options, (lambda do |text:, url:, selected: false|
link_to(text, url, class: "dropdown-item #{'active' if selected}", role: 'menuitem', aria: { current: ('page' if selected) })
link_to(text, url, class: "dropdown-item #{'active' if selected}", aria: { current: ('page' if selected) })
end)

# rubocop:disable Metrics/ParameterLists
Expand Down
26 changes: 26 additions & 0 deletions spec/components/blacklight/system/dropdown_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Blacklight::System::DropdownComponent, type: :component do
it 'includes a link for each choice' do
search_state = double(Blacklight::SearchState)
allow(search_state).to receive(:params_for_search).and_return('http://example.com')
rendered = render_inline(described_class.new(
param: :per_page,
choices: [
['10 per page', 10],
['20 per page', 20]
],
search_state: search_state,
selected: 20,
interpolation: :count
))

expect(rendered.css('a').length).to eq 2
expect(rendered.css('a')[0].text).to eq '10 per page'
expect(rendered.css('a')[0].attributes).not_to have_key 'aria-current'
expect(rendered.css('a')[1].text).to eq '20 per page'
expect(rendered.css('a')[1].attributes).to have_key 'aria-current'
end
end

0 comments on commit bd1b73e

Please sign in to comment.