Skip to content

Commit

Permalink
Merge pull request #3495 from projectblacklight/i3494-relevant-facet-…
Browse files Browse the repository at this point in the history
…suggest

Ensure that facet suggestions are relevant to the user's query
  • Loading branch information
jcoyne authored Jan 27, 2025
2 parents 8ee533f + f3a53b5 commit e5618b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/javascript/blacklight-frontend/facet_suggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const FacetSuggest = async (e) => {
const facetField = e.target.dataset.facetField;
if (!facetField) { return; }

const urlToFetch = `/catalog/facet_suggest/${facetField}/${queryFragment}`
const urlToFetch = `/catalog/facet_suggest/${facetField}/${queryFragment}${window.location.search}`
const response = await fetch(urlToFetch);
if (response.ok) {
const blob = await response.blob()
Expand Down
8 changes: 8 additions & 0 deletions spec/features/facets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,13 @@
expect(page).to have_link 'Old age'
expect(page).to have_css 'a.facet-select', count: 2
end

it 'shows the user facet suggestions that are relevant to their q param', :js do
visit '/catalog/facet/subject_ssim?q=tibet&search_field=all_fields'
fill_in 'facet_suggest_subject_ssim', with: 'la'

expect(page).to have_link 'Tibetan language'
expect(page).to have_css 'a.facet-select', count: 1
end
end
end

0 comments on commit e5618b6

Please sign in to comment.