Skip to content

Commit

Permalink
Conditionally add "documents" id to search results
Browse files Browse the repository at this point in the history
  • Loading branch information
lfarrell authored Dec 12, 2023
1 parent 8a74a01 commit e866e15
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
8 changes: 8 additions & 0 deletions app/views/catalog/_document_list.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% # Override to conditionally add id="documents" on div. When documents are grouped it causes duplicate id issues %>
<% # https://github.com/projectblacklight/blacklight/blob/v8.1.0/app/views/catalog/_document_list.html.erb %>
<% # container for all documents in index list view -%>
<% view_config = local_assigns[:view_config] || blacklight_config&.view_config(document_index_view_type) %>
<div <%= 'id="documents"'.html_safe unless grouped? %> class="al-document-listings documents-<%= view_config&.key || document_index_view_type %>">
<% document_presenters = documents.map { |doc| document_presenter(doc) } -%>
<%= render view_config.document_component.with_collection(document_presenters, partials: view_config.partials, counter_offset: @response&.start || 0) %>
</div>
2 changes: 1 addition & 1 deletion app/views/catalog/_group.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% # container for all groups in index view -%>
<div class='al-grouped-results'>
<div id="documents" class='al-grouped-results'>
<%= render (blacklight_config.view_config(document_index_view_type).group_component || Arclight::GroupComponent).with_collection(@response.groups) %>
</div>
6 changes: 3 additions & 3 deletions spec/features/collection_filtering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

click_button 'Search'

expect(page).to have_css('#documents .document', count: 10) # has results
expect(page).to have_css('.al-document-listings .document', count: 10) # has results
expect(page).not_to have_css('.constraint-value .filter-value', text: 'Alpha Omega Alpha Archives, 1894-1992')
end
end
Expand Down Expand Up @@ -52,7 +52,7 @@
click_button 'Search'

expect(page).to have_css('.constraint-value .filter-value', text: 'Alpha Omega Alpha Archives, 1894-1992')
expect(page).to have_css('#documents .document', count: 1) # has results
expect(page).to have_css('.al-document-listings .document', count: 1) # has results
end

it 'allows the user to choose to search all collections' do
Expand All @@ -63,7 +63,7 @@
click_button 'Search'

expect(page).not_to have_css('.constraint-value .filter-value', text: 'Alpha Omega Alpha Archives, 1894-1992')
expect(page).to have_css('#documents .document', count: 10) # has results
expect(page).to have_css('.al-document-listings .document', count: 10) # has results
end
end
end
4 changes: 2 additions & 2 deletions spec/features/collection_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@
it 'clicking contents does not change the session results view context' do
visit search_catalog_path q: '', search_field: 'all_fields'

expect(page).to have_css('#documents.documents-list')
expect(page).not_to have_css('#documents.documents-hierarchy')
expect(page).to have_css('.al-document-listings.documents-list')
expect(page).not_to have_css('.al-document-listings.documents-hierarchy')
end
end
end
Expand Down

0 comments on commit e866e15

Please sign in to comment.