Skip to content

Commit

Permalink
PI-1449 Fix search suggestions for multi-term queries
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-bcl committed Sep 21, 2023
1 parent 4f6decc commit 3af458b
Show file tree
Hide file tree
Showing 5 changed files with 1,376 additions and 714 deletions.
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 3af458b

Please sign in to comment.