Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#3518] Remove incomplete implementation of menu aria role from Blacklight::System::DropdownComponent #3519

Merged
merged 1 commit into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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