Skip to content

Commit

Permalink
Add search element to site search
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Dec 17, 2023
1 parent d9610d6 commit b1011e7
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions components/site-search/site-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@ export class SiteSearchElement extends HTMLElement {
}
}

searchLabelTemplate() {
const element = document.createElement('label')
element.classList.add('govuk-visually-hidden')
element.htmlFor = this.searchInputId
element.textContent = this.searchLabel
searchTemplate() {
const labelElement = document.createElement('label')
labelElement.classList.add('govuk-visually-hidden')
labelElement.htmlFor = this.searchInputId
labelElement.textContent = this.searchLabel

return element
const searchElement = document.createElement('search')
searchElement.append(labelElement)

return searchElement
}

resultTemplate(result) {
Expand Down Expand Up @@ -109,12 +112,12 @@ export class SiteSearchElement extends HTMLElement {
this.sitemapLink.remove()
}

// Add label for search input
const label = this.searchLabelTemplate()
this.append(label)
// Add `search` element with `label`
const search = this.searchTemplate()
this.append(search)

accessibleAutocomplete({
element: this,
element: search,
id: this.searchInputId,
cssNamespace: 'app-site-search',
displayMenu: 'overlay',
Expand Down

0 comments on commit b1011e7

Please sign in to comment.