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

Add additional accessible text to linked faceted searches #3428

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion app/presenters/blacklight/rendering/link_to_facet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ def link_field
end

def link(field, v)
context.link_to v, search_path(field, v)
context.link_to search_path(field, v) do
context.tag.span(v) +
context.tag.span(search_description, class: 'visually-hidden')
end
end

def search_path(field, v)
context.search_action_path(facet_params(field, v))
end

# Accessible description for the link, indicating it will do a faceted search
def search_description
context.t 'blacklight.search.facets.faceted_search', field_label: config.display_label
end

def facet_params(field, item)
context.search_state.reset.filter(field).add(item).params
end
Expand Down
1 change: 1 addition & 0 deletions config/locales/blacklight.ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ ar:
all: الكل
clear: إزالة معايير البحث
count: "%{number}"
faceted_search: بحث %{field_label}
group:
close: إخفاء الأوجه
open: عرض الأوجه
Expand Down
1 change: 1 addition & 0 deletions config/locales/blacklight.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ de:
all: Alle
clear: Löschen
count: "%{number}"
faceted_search: "%{field_label} Suche"
group:
close: Facetten ausblenden
open: Facetten zeigen
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 @@ -124,6 +124,7 @@ en:
label: "Filter %{field_label}"
placeholder: Filter...
title: Limit your search
faceted_search: "%{field_label} search"
filters:
label: "%{label}:"
remove:
Expand Down
1 change: 1 addition & 0 deletions config/locales/blacklight.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ es:
all: Todos
clear: Borrar
count: "%{number}"
faceted_search: Búsqueda %{field_label}
group:
close: Ocultar facetas
open: Mostrar facetas
Expand Down
1 change: 1 addition & 0 deletions config/locales/blacklight.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ fr:
all: Tout
clear: Effacer
count: "%{number}"
faceted_search: Recherche %{field_label}
group:
close: Masquer les facettes
open: Afficher les facettes
Expand Down
1 change: 1 addition & 0 deletions config/locales/blacklight.hu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ hu:
all: Minden
clear: Szűrőfeltétel eltávolítása
count: "%{number}"
faceted_search: "%{field_label} keresés"
group:
close: Fazetek elrejtése
open: Szempontok megjelenítése
Expand Down
1 change: 1 addition & 0 deletions config/locales/blacklight.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ it:
all: Ogni
clear: Cancella
count: "%{number}"
faceted_search: "%{field_label} ricerca"
group:
close: Nascondi sfaccettature
open: Mostra sfaccettature
Expand Down
1 change: 1 addition & 0 deletions config/locales/blacklight.nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ nl:
all: Al
clear: Filters legen
count: "%{number}"
faceted_search: "%{field_label} zoeken"
group:
close: Verberg facetten
open: Toon facetten
Expand Down
1 change: 1 addition & 0 deletions config/locales/blacklight.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pt-BR:
all: Todo
clear: Limpar
count: "%{number}"
faceted_search: Pesquisa %{field_label}
group:
close: Ocultar facetas
open: Mostrar facetas
Expand Down
1 change: 1 addition & 0 deletions config/locales/blacklight.sq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ sq:
all: Gjithë
clear: Fshij filterin
count: "%{number}"
faceted_search: "%{field_label} kërkim"
group:
close: Fshih aspektet
open: Trego aspektet
Expand Down
1 change: 1 addition & 0 deletions config/locales/blacklight.zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ zh:
all: 皆
clear: 清除搜索条件
count: "%{number}"
faceted_search: "%{field_label} 搜索"
group:
close: 隐藏方面
open: 显示方面
Expand Down
4 changes: 2 additions & 2 deletions spec/presenters/blacklight/field_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def render
context 'when field has link_to_facet with true' do
before do
allow(request_context).to receive(:search_action_path).with({ 'f' => { 'link_to_facet_true' => ['x'] } }).and_return('/foo')
allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
allow(request_context).to receive(:link_to).with('/foo').and_return('bar')
end

let(:field_name) { 'link_to_facet_true' }
Expand All @@ -94,7 +94,7 @@ def render
context 'when field has link_to_facet with a field name' do
before do
allow(request_context).to receive(:search_action_path).with({ 'f' => { 'some_field' => ['x'] } }).and_return('/foo')
allow(request_context).to receive(:link_to).with("x", '/foo').and_return('bar')
allow(request_context).to receive(:link_to).with('/foo').and_return('bar')
end

let(:field_name) { 'link_to_facet_named' }
Expand Down
24 changes: 24 additions & 0 deletions spec/presenters/blacklight/rendering/link_to_facet_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

RSpec.describe Blacklight::Rendering::LinkToFacet, type: :presenter do
include Capybara::RSpecMatchers

let(:field_config) { Blacklight::Configuration::FacetField.new(link_to_facet: true, key: 'field', label: 'Field') }
let(:document) { instance_double(SolrDocument) }
let(:blacklight_config) { Blacklight::Configuration.new }
let(:view_context) { controller.view_context }
let(:value) { 'value' }
let(:pipeline) { Blacklight::Rendering::Pipeline.new([value], field_config, document, view_context, [described_class], {}) }

describe '#render' do
subject { pipeline.render[0] }

it 'renders the value' do
expect(subject).to have_css('span', text: 'value')
end

it 'renders the accessible description as visually hidden' do
expect(subject).to have_css('span.visually-hidden', text: 'Field search')
end
end
end