Skip to content

Commit 11e1baa

Browse files
committed
updates from review
1 parent 4aa28b3 commit 11e1baa

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

README.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,32 +83,31 @@ In your prototype folder, run:
8383
npm install accessible-autocomplete
8484
```
8585

86-
This will load the accessible autocomplete CSS and JavaScript for you.
87-
88-
Then on the page you want to add the accessible autocomplete:
86+
To add the accessible autocomplete to a page in your prototype, first add a `select` component with your options. For example:
8987

9088
```html
91-
<label for="my-autocomplete">Select your country</label>
92-
<div id="my-autocomplete-container"></div>
89+
<div class="govuk-form-group">
90+
<label class="govuk-label" for="country">
91+
Country
92+
</label>
93+
<select class="govuk-select" id="country" name="country">
94+
<option value="England">England</option>
95+
<option value="Northern Ireland">Northern Ireland</option>
96+
<option value="Scotland">Scotland</option>
97+
<option value="Wales">Wales</option>
98+
</select>
99+
</div>
93100
```
94101

95-
At the end of the file add a `pageScripts` block for the JavaScript:
102+
At the end of the same page add a `pageScripts` block for the JavaScript. This turns the `select` into an autocomplete.
96103

97104
```js
98105
<% block pageScripts %>
99106

100107
<script>
101108

102-
const countries = [
103-
'France',
104-
'Germany',
105-
'United Kingdom'
106-
]
107-
108-
accessibleAutocomplete({
109-
element: document.querySelector('#my-autocomplete-container'),
110-
id: 'my-autocomplete', // To match it to the existing <label>.
111-
source: countries
109+
accessibleAutocomplete.enhanceSelectElement({
110+
selectElement: document.querySelector('#country')
112111
})
113112

114113
</script>
@@ -117,8 +116,6 @@ At the end of the file add a `pageScripts` block for the JavaScript:
117116

118117
```
119118

120-
If you want to use it as a replacement for a `<select>` element, read the [Progressive enhancement](#progressive-enhancement) section.
121-
122119
### Styling the autocomplete
123120

124121
A stylesheet is included with the package at [dist/accessible-autocomplete.min.css](dist/accessible-autocomplete.min.css).

0 commit comments

Comments
 (0)