Skip to content

Commit

Permalink
PI-1449 Fix search suggestions for multi-term queries (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-bcl authored Sep 22, 2023
1 parent 4f6decc commit 37587b3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6,802 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
Did you mean
{%- set comma = joiner() %}
{%- for suggestion in params.results.suggestions %}{{ comma() }}
<a href="?q={{ suggestion }}" class="govuk-link govuk-link--no-visited-state"
title="Search again using {{ suggestion }}">{{ suggestion }}</a>
<a href="{{ suggestion.url }}" class="govuk-link govuk-link--no-visited-state"
title="Search again using {{ suggestion.text }}">{{ suggestion.text }}</a>
{%- endfor %}?
{% endif %}
</p>
Expand All @@ -46,7 +46,8 @@
document.getElementById("{{ params.id }}").addEventListener('input', function() {
clearTimeout(timeoutId)
const url = new URL(location.href)
url.searchParams.forEach((value, name) => url.searchParams.delete(name))
url.searchParams.delete("matchAllTerms")
url.searchParams.delete("providers[]")
url.searchParams.set('q', this.value)
timeoutId = setTimeout(() => fetch(url).then(async response => {
if (response.status === 200) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ export interface ProbationSearchResult {

export interface Suggestion {
text: string
offset: number
length: number
options: {
text: string
freq: number
Expand Down
Loading

0 comments on commit 37587b3

Please sign in to comment.