Skip to content

Commit

Permalink
Merge pull request #3068 from projectblacklight/adv-aria-labels
Browse files Browse the repository at this point in the history
Add explicit labeling for select tags
  • Loading branch information
jcoyne authored Aug 10, 2023
2 parents b383961 + 552e07f commit b3d30bd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<% if sort_fields_select %>
<div class="form-group row mb-4">
<%= content_tag :h2, t('blacklight.advanced_search.form.sort_label'), class: 'col-md-3 col-form-label text-md-right' %>
<%= content_tag :h2, t('blacklight.advanced_search.form.sort_label'), id: 'advanced-search-sort-label', class: 'col-md-3 col-form-label text-md-right' %>
<div class="col">
<%= sort_fields_select %>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/components/blacklight/advanced_search_form_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def before_render

def default_operator_menu
options_with_labels = [:must, :should].index_by { |op| t(op, scope: 'blacklight.advanced_search.op') }
select_tag(:op, options_for_select(options_with_labels, params[:op]), class: 'input-small')
label_tag(:op, t('blacklight.advanced_search.op.label'), class: 'sr-only visually-hidden') + select_tag(:op, options_for_select(options_with_labels, params[:op]), class: 'input-small')
end

def sort_fields_select
options = sort_fields.values.map { |field_config| [helpers.sort_field_label(field_config.key), field_config.key] }
return unless options.any?

select_tag(:sort, options_for_select(options, params[:sort]), class: "form-select custom-select sort-select w-auto")
select_tag(:sort, options_for_select(options, params[:sort]), class: "form-select custom-select sort-select w-auto", aria: { labelledby: 'advanced-search-sort-label' })
end

private
Expand Down
1 change: 1 addition & 0 deletions config/locales/blacklight.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ en:
more_options: More options
any_of: 'Any of:'
op:
label: search operator
must: all
should: any
page_title: Advanced search - %{application_name}
Expand Down
5 changes: 5 additions & 0 deletions spec/features/axe_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
expect(page).to be_accessible
end

it 'validates the advanced search form' do
visit advanced_search_catalog_path
expect(page).to be_accessible
end

it 'validates the single results page' do
visit solr_document_path('2007020969')
expect(page).to be_accessible
Expand Down

0 comments on commit b3d30bd

Please sign in to comment.