Skip to content

Commit

Permalink
Merge pull request #673 from DFE-Digital/fix-search-url
Browse files Browse the repository at this point in the history
Fix search url by removing UID
  • Loading branch information
nwarms authored Dec 19, 2024
2 parents a637f3f + 8d53a48 commit b944955
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased][unreleased]

### Changed

- Updated the autocomplete so that searching clears the selected trust

## [Release-17][release-17] (production-2024-12-18.4551)

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import accessibleAutocomplete from 'accessible-autocomplete'

export class Autocomplete {
suggest = async (query, populateResults) => {
suggest = async (query, populateResults, inputId) => {
// Clear selected trust if we then search for new trust
// Avoids the uid turning up in the url
const searchInput = document.getElementById(`${inputId}-selected-trust`)
if (searchInput.hasAttribute('value')) {
searchInput.removeAttribute('value')
}

if (query) {
const response = await fetch(`/search?handler=populateautocomplete&keywords=${query}`)
const results = await response.json()
Expand Down Expand Up @@ -35,7 +42,7 @@ export class Autocomplete {
element: document.getElementById(`${inputId}-autocomplete-container`),
id: inputId,
name: 'keywords',
source: this.suggest,
source: async (query, populateResults) => this.suggest(query, populateResults, inputId),
autoselect: false,
confirmOnBlur: false,
displayMenu: 'overlay',
Expand Down

0 comments on commit b944955

Please sign in to comment.