@ministryofjustice/hmpps-connect-dps-shared-items 4.2.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -51,7 +51,7 @@ export class AutosuggestUi {
|
|
|
51
51
|
this.resultOptions = []
|
|
52
52
|
this.data = []
|
|
53
53
|
this.numberOfResults = 0
|
|
54
|
-
this.highlightedResultIndex =
|
|
54
|
+
this.highlightedResultIndex = null
|
|
55
55
|
this.blurring = false
|
|
56
56
|
this.blurTimeout = null
|
|
57
57
|
this.scrolling = false
|
|
@@ -243,6 +243,7 @@ export class AutosuggestUi {
|
|
|
243
243
|
this.context.classList.remove(`${this.stylingBaseClass}${classSuffixHasResults}`)
|
|
244
244
|
this.input.removeAttribute('aria-activedescendant')
|
|
245
245
|
this.input.setAttribute('aria-expanded', false)
|
|
246
|
+
this.setHighlightedResult(null)
|
|
246
247
|
this.setAriaStatus()
|
|
247
248
|
}
|
|
248
249
|
|
|
@@ -260,7 +261,7 @@ export class AutosuggestUi {
|
|
|
260
261
|
return listElement
|
|
261
262
|
}) ?? []
|
|
262
263
|
|
|
263
|
-
this.setHighlightedResult(
|
|
264
|
+
this.setHighlightedResult(null)
|
|
264
265
|
this.input.setAttribute('aria-expanded', this.numberOfResults ? 'true' : 'false')
|
|
265
266
|
|
|
266
267
|
if (!!this.numberOfResults && this.sanitisedQuery.length >= this.minChars) {
|
|
@@ -322,9 +323,11 @@ export class AutosuggestUi {
|
|
|
322
323
|
|
|
323
324
|
if (this.highlightedResultIndex === null) {
|
|
324
325
|
this.input.removeAttribute('aria-activedescendant')
|
|
325
|
-
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (this.numberOfResults) {
|
|
326
329
|
this.resultOptions.forEach((option, optionIndex) => {
|
|
327
|
-
if (optionIndex === index) {
|
|
330
|
+
if (index !== null && optionIndex === index) {
|
|
328
331
|
if (this.isAboveViewport(option)) {
|
|
329
332
|
this.handleScroll(option, true)
|
|
330
333
|
}
|
|
@@ -347,7 +350,12 @@ export class AutosuggestUi {
|
|
|
347
350
|
selectResult(index) {
|
|
348
351
|
if (!this.results.length) return
|
|
349
352
|
|
|
350
|
-
const
|
|
353
|
+
const selectedIndex = typeof index === 'number' ? index : this.highlightedResultIndex
|
|
354
|
+
if (selectedIndex === null || selectedIndex === undefined) return
|
|
355
|
+
|
|
356
|
+
const result = this.results[selectedIndex]
|
|
357
|
+
if (!result) return
|
|
358
|
+
|
|
351
359
|
this.onSelect(result)
|
|
352
360
|
this.clearListbox()
|
|
353
361
|
this.setAriaStatus(`${this.ariaYouHaveSelected}: ${result.displayText}.`)
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
class="hmpps-address-autosuggest__instructions hmpps-js-autosuggest-instructions govuk-visually-hidden"
|
|
45
45
|
id="address-autosuggest-instructions"
|
|
46
46
|
tabindex="-1">
|
|
47
|
-
Use up and down keys to navigate suggestions once you have typed
|
|
47
|
+
Use up and down keys to navigate suggestions once you have typed three or more characters. Use the enter key to select a
|
|
48
48
|
suggestion. Touch device users, explore by touch or with swipe gestures.
|
|
49
49
|
</div>
|
|
50
50
|
<div
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ministryofjustice/hmpps-connect-dps-shared-items",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "A package to share Connect DPS functionality across applications",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"jest-html-reporter": "^4.4.0",
|
|
64
64
|
"jest-junit": "^17.0.0",
|
|
65
65
|
"lint-staged": "^17.2.0",
|
|
66
|
-
"nock": "14.0.
|
|
67
|
-
"rollup": "4.62.
|
|
68
|
-
"rollup-plugin-dts": "6.
|
|
66
|
+
"nock": "14.0.17",
|
|
67
|
+
"rollup": "4.62.4",
|
|
68
|
+
"rollup-plugin-dts": "6.5.1",
|
|
69
69
|
"ts-jest": "29.4.12",
|
|
70
70
|
"tslib": "^2.8.1",
|
|
71
71
|
"typescript": "6.0.3"
|