Skip to content

Commit

Permalink
Merge 3dfcab4 into 87b3250
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jul 9, 2020
2 parents 87b3250 + 3dfcab4 commit 5b76b33
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
20 changes: 9 additions & 11 deletions app/helpers/blacklight/hierarchy_helper.rb
Expand Up @@ -122,17 +122,15 @@ def facet_toggle_button(field_name, described_by)
"blacklight.hierarchy.#{field_name}_toggle_aria_label",
default: :'blacklight.hierarchy.toggle_aria_label'
)
<<-HTML
<button
aria-expanded="false"
aria-label="#{aria_label}"
aria-describedby="#{described_by}"
class="toggle-handle"
>
<span aria-hidden="true" class="closed">#{Blacklight::Hierarchy::Engine.config.closed_icon}</span>
<span aria-hidden="true" class="opened">#{Blacklight::Hierarchy::Engine.config.opened_icon}</span>
</button>
HTML

# For Rails 5.2 support all options must be symbols. See https://github.com/rails/rails/issues/39813
tag.button(:'aria-expanded' => 'false',
:'aria-label' => aria_label,
:'aria-describedby' => described_by,
class: 'toggle-handle') do
tag.span(Blacklight::Hierarchy::Engine.config.closed_icon, :'aria-hidden' => 'true', class: 'closed') +
tag.span(Blacklight::Hierarchy::Engine.config.opened_icon, :'aria-hidden' => 'true', class: 'opened')
end
end

# --------------------------------------------------------------------------------------------------------------------------------
Expand Down
10 changes: 9 additions & 1 deletion spec/helpers/hierarchy_helper_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'

describe Blacklight::HierarchyHelper do
RSpec.describe Blacklight::HierarchyHelper do
describe '#render_hierarchy' do
it 'should remove the _suffix from the field name' do
expect(Deprecation).to receive(:warn)
Expand All @@ -9,4 +9,12 @@
helper.render_hierarchy(field)
end
end

describe '#facet_toggle_button' do
subject { helper.facet_toggle_button(field_name, described_by) }
let(:field_name) { 'exploded_tag_ssim' }
let(:described_by) { 'unique-string' }

it { is_expected.to be_html_safe }
end
end

0 comments on commit 5b76b33

Please sign in to comment.