hmrc-frontend 6.47.0 → 6.50.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.
- package/hmrc/VERSION.txt +1 -1
- package/hmrc/{accessible-autocomplete-6.47.0.css → accessible-autocomplete-6.50.0.css} +2 -2
- package/hmrc/{accessible-autocomplete-6.47.0.js → accessible-autocomplete-6.50.0.js} +35 -7
- package/hmrc/accessible-autocomplete.scss +14 -0
- package/hmrc/all.js +5 -8
- package/hmrc/components/accessible-autocomplete/__tests__/2024-12-adams-polyfill.js.txt +119 -0
- package/hmrc/components/accessible-autocomplete/accessible-autocomplete.js +44 -6
- package/hmrc/components/timeout-dialog/_timeout-dialog.scss +6 -14
- package/hmrc/components/timeout-dialog/timeout-dialog.js +7 -10
- package/hmrc/{hmrc-frontend-6.47.0.min.css → hmrc-frontend-6.50.0.min.css} +2 -2
- package/hmrc/{hmrc-frontend-6.47.0.min.js → hmrc-frontend-6.50.0.min.js} +2 -2
- package/hmrc/maps/accessible-autocomplete-6.50.0.css.map +1 -0
- package/hmrc/maps/hmrc-frontend-6.50.0.min.css.map +1 -0
- package/hmrc/maps/hmrc-frontend-6.50.0.min.js.map +1 -0
- package/package.json +1 -1
- package/hmrc/maps/accessible-autocomplete-6.47.0.css.map +0 -1
- package/hmrc/maps/hmrc-frontend-6.47.0.min.css.map +0 -1
- package/hmrc/maps/hmrc-frontend-6.47.0.min.js.map +0 -1
package/hmrc/VERSION.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
6.
|
|
1
|
+
6.50.0
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.autocomplete__wrapper{position:relative}.autocomplete__hint,.autocomplete__input{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:2px solid #0b0c0c;border-radius:0;-webkit-box-sizing:border-box;box-sizing:border-box;height:2.5rem;line-height:1.25;margin-bottom:0;width:100%}.autocomplete__input{background-color:rgba(0,0,0,0);position:relative}.autocomplete__hint{color:#505a5f;position:absolute}.autocomplete__input--default{padding:5px}.autocomplete__input--focused{-webkit-box-shadow:inset 0 0 0 2px;box-shadow:inset 0 0 0 2px;outline:3px solid #fd0;outline-offset:0}.autocomplete__input--show-all-values{cursor:pointer;padding:5px 35px 5px 5px}.autocomplete__dropdown-arrow-down{display:inline-block;height:24px;position:absolute;right:8px;top:10px;width:24px;z-index:-1}.autocomplete__menu{background-color:#fff;border:2px solid #0b0c0c;border-top:0;color:#0b0c0c;margin:0;max-height:342px;overflow-x:hidden;padding:0;width:100%;width:calc(100% - 4px)}.autocomplete__menu--visible{display:block}.autocomplete__menu--hidden{display:none}.autocomplete__menu--overlay{-webkit-box-shadow:0 2px 6px rgba(0,0,0,.257);box-shadow:0 2px 6px rgba(0,0,0,.257);left:0;position:absolute;top:100%;z-index:100}.autocomplete__menu--inline{position:relative}.autocomplete__option{border-bottom:1px solid #b1b4b6;border-left-width:0;border-right-width:0;border-top-width:1px;cursor:pointer;display:block;position:relative}.autocomplete__option>*{pointer-events:none}.autocomplete__option:first-of-type{border-top-width:0}.autocomplete__option:last-of-type{border-bottom-width:0}.autocomplete__option--odd{background-color:#f3f2f1}.autocomplete__option--focused,.autocomplete__option:hover{background-color:#1d70b8;border-color:#1d70b8;color:#fff;outline:none}@media (-ms-high-contrast:active),(forced-colors:active){.autocomplete__menu{border-color:FieldText}.autocomplete__option{background-color:Field;color:FieldText}.autocomplete__option--focused,.autocomplete__option:hover{background-color:Highlight;background-color:SelectedItem;border-color:SelectedItem;color:HighlightText;color:SelectedItemText;forced-color-adjust:none;outline-color:SelectedItemText}}.autocomplete__option--no-results{background-color:#f3f2f1;color:#505a5f;cursor:not-allowed}.autocomplete__hint,.autocomplete__input,.autocomplete__option{font-size:1rem;font-weight:400}.autocomplete__hint,.autocomplete__option{padding:5px}@media (min-width:641px){.autocomplete__hint,.autocomplete__input,.autocomplete__option{font-size:1.1875rem;line-height:1.3157894737}}.autocomplete__hint,.autocomplete__input,.autocomplete__option,.autocomplete__wrapper{font-family:GDS Transport,arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-weight:400;font-size:1rem;line-height:1.25}@media print{.autocomplete__hint,.autocomplete__input,.autocomplete__option,.autocomplete__wrapper{font-family:sans-serif}}@media (min-width:40.0625em){.autocomplete__hint,.autocomplete__input,.autocomplete__option,.autocomplete__wrapper{font-size:1.1875rem;line-height:1.3157894737}}@media print{.autocomplete__hint,.autocomplete__input,.autocomplete__option,.autocomplete__wrapper{font-size:14pt;line-height:1.15}}
|
|
2
|
-
/*# sourceMappingURL=maps/accessible-autocomplete-6.
|
|
1
|
+
.autocomplete__wrapper{position:relative}.autocomplete__hint,.autocomplete__input{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:2px solid #0b0c0c;border-radius:0;-webkit-box-sizing:border-box;box-sizing:border-box;height:2.5rem;line-height:1.25;margin-bottom:0;width:100%}.autocomplete__input{background-color:rgba(0,0,0,0);position:relative}.autocomplete__hint{color:#505a5f;position:absolute}.autocomplete__input--default{padding:5px}.autocomplete__input--focused{-webkit-box-shadow:inset 0 0 0 2px;box-shadow:inset 0 0 0 2px;outline:3px solid #fd0;outline-offset:0}.autocomplete__input--show-all-values{cursor:pointer;padding:5px 35px 5px 5px}.autocomplete__dropdown-arrow-down{display:inline-block;height:24px;position:absolute;right:8px;top:10px;width:24px;z-index:-1}.autocomplete__menu{background-color:#fff;border:2px solid #0b0c0c;border-top:0;color:#0b0c0c;margin:0;max-height:342px;overflow-x:hidden;padding:0;width:100%;width:calc(100% - 4px)}.autocomplete__menu--visible{display:block}.autocomplete__menu--hidden{display:none}.autocomplete__menu--overlay{-webkit-box-shadow:0 2px 6px rgba(0,0,0,.257);box-shadow:0 2px 6px rgba(0,0,0,.257);left:0;position:absolute;top:100%;z-index:100}.autocomplete__menu--inline{position:relative}.autocomplete__option{border-bottom:1px solid #b1b4b6;border-left-width:0;border-right-width:0;border-top-width:1px;cursor:pointer;display:block;position:relative}.autocomplete__option>*{pointer-events:none}.autocomplete__option:first-of-type{border-top-width:0}.autocomplete__option:last-of-type{border-bottom-width:0}.autocomplete__option--odd{background-color:#f3f2f1}.autocomplete__option--focused,.autocomplete__option:hover{background-color:#1d70b8;border-color:#1d70b8;color:#fff;outline:none}@media (-ms-high-contrast:active),(forced-colors:active){.autocomplete__menu{border-color:FieldText}.autocomplete__option{background-color:Field;color:FieldText}.autocomplete__option--focused,.autocomplete__option:hover{background-color:Highlight;background-color:SelectedItem;border-color:SelectedItem;color:HighlightText;color:SelectedItemText;forced-color-adjust:none;outline-color:SelectedItemText}}.autocomplete__option--no-results{background-color:#f3f2f1;color:#505a5f;cursor:not-allowed}.autocomplete__hint,.autocomplete__input,.autocomplete__option{font-size:1rem;font-weight:400}.autocomplete__hint,.autocomplete__option{padding:5px}@media (min-width:641px){.autocomplete__hint,.autocomplete__input,.autocomplete__option{font-size:1.1875rem;line-height:1.3157894737}}.autocomplete__hint,.autocomplete__input,.autocomplete__option,.autocomplete__wrapper{font-family:GDS Transport,arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-weight:400;font-size:1rem;line-height:1.25}@media print{.autocomplete__hint,.autocomplete__input,.autocomplete__option,.autocomplete__wrapper{font-family:sans-serif}}@media (min-width:40.0625em){.autocomplete__hint,.autocomplete__input,.autocomplete__option,.autocomplete__wrapper{font-size:1.1875rem;line-height:1.3157894737}}@media print{.autocomplete__hint,.autocomplete__input,.autocomplete__option,.autocomplete__wrapper{font-size:14pt;line-height:1.15}}.govuk-form-group--error div:has(+.govuk-select--error[data-module=hmrc-accessible-autocomplete])>.autocomplete__wrapper .autocomplete__input{border-color:#d4351c}.autocomplete__dropdown-arrow-down{z-index:0;pointer-events:none}
|
|
2
|
+
/*# sourceMappingURL=maps/accessible-autocomplete-6.50.0.css.map */
|
|
@@ -2851,18 +2851,30 @@
|
|
|
2851
2851
|
}
|
|
2852
2852
|
AccessibleAutoComplete.prototype.init = function init() {
|
|
2853
2853
|
if (this.$module) {
|
|
2854
|
-
var
|
|
2855
|
-
var
|
|
2856
|
-
var
|
|
2857
|
-
var
|
|
2854
|
+
var selectElement = this.$module;
|
|
2855
|
+
var selectOptions = Array.from(selectElement.options);
|
|
2856
|
+
var autocompleteId = selectElement.id;
|
|
2857
|
+
var showAllValues = selectElement.getAttribute('data-show-all-values') === 'true';
|
|
2858
|
+
var autoselect = selectElement.getAttribute('data-auto-select') === 'true';
|
|
2859
|
+
var defaultValue = selectElement.getAttribute('data-default-value');
|
|
2860
|
+
var minLength = selectElement.getAttribute('data-min-length');
|
|
2858
2861
|
var configurationOptions = {
|
|
2859
|
-
selectElement:
|
|
2862
|
+
selectElement: selectElement,
|
|
2860
2863
|
showAllValues: showAllValues,
|
|
2861
2864
|
autoselect: autoselect,
|
|
2862
2865
|
defaultValue: defaultValue,
|
|
2863
|
-
minLength: minLength
|
|
2866
|
+
minLength: minLength,
|
|
2867
|
+
onConfirm: function onConfirm(chosenOption) {
|
|
2868
|
+
var _document$getElementB;
|
|
2869
|
+
selectElement.value = '';
|
|
2870
|
+
var chosenOptionOrCurrentValue = typeof chosenOption !== 'undefined' ? chosenOption : (_document$getElementB = document.getElementById(autocompleteId)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.value;
|
|
2871
|
+
var selectedOption = [].filter.call(selectOptions, function (option) {
|
|
2872
|
+
return (option.textContent || option.innerText) === chosenOptionOrCurrentValue;
|
|
2873
|
+
})[0];
|
|
2874
|
+
if (selectedOption) selectedOption.selected = true;
|
|
2875
|
+
}
|
|
2864
2876
|
};
|
|
2865
|
-
var language =
|
|
2877
|
+
var language = selectElement.getAttribute('data-language') || 'en';
|
|
2866
2878
|
if (language === 'cy') {
|
|
2867
2879
|
configurationOptions.tAssistiveHint = function () {
|
|
2868
2880
|
return 'Pan fydd canlyniadau awtogwblhau ar gael, defnyddiwch y saethau i fyny ac i lawr i’w hadolygu a phwyswch y fysell ’enter’ i’w dewis.' + ' Gall defnyddwyr dyfeisiau cyffwrdd, archwilio drwy gyffwrdd â’r sgrin neu drwy sweipio.';
|
|
@@ -2885,6 +2897,22 @@
|
|
|
2885
2897
|
};
|
|
2886
2898
|
}
|
|
2887
2899
|
window.HMRCAccessibleAutocomplete.enhanceSelectElement(configurationOptions);
|
|
2900
|
+
var selectElementAriaDescribedBy = selectElement.getAttribute('aria-describedby') || '';
|
|
2901
|
+
var autocompleteElement = document.getElementById(autocompleteId);
|
|
2902
|
+
var autocompleteElementAriaDescribedBy = autocompleteElement && autocompleteElement.getAttribute('aria-describedby') || '';
|
|
2903
|
+
var autocompleteElementMissingAriaDescribedAttrs = autocompleteElement && autocompleteElement.tagName !== 'select' && !autocompleteElementAriaDescribedBy.includes(selectElementAriaDescribedBy);
|
|
2904
|
+
if (autocompleteElementMissingAriaDescribedAttrs) {
|
|
2905
|
+
// if there is a hint and/or error then the autocomplete element
|
|
2906
|
+
// needs to be aria-describedby these, which it isn't be default
|
|
2907
|
+
// we need to check if it hasn't already been done to avoid
|
|
2908
|
+
autocompleteElement.setAttribute('aria-describedby', "".concat(selectElementAriaDescribedBy, " ").concat(autocompleteElementAriaDescribedBy));
|
|
2909
|
+
// and in case page is still using adam's patch, this should stop
|
|
2910
|
+
// the select elements aria described by being added to the
|
|
2911
|
+
// autocomplete element twice when that runs (though unsure if a
|
|
2912
|
+
// screen reader would actually announce the elements twice if same
|
|
2913
|
+
// element was listed twice in the aria-describedby attribute)
|
|
2914
|
+
selectElement.setAttribute('aria-describedby', '');
|
|
2915
|
+
}
|
|
2888
2916
|
}
|
|
2889
2917
|
};
|
|
2890
2918
|
|
|
@@ -11,3 +11,17 @@ $govuk-include-default-font-face: false;
|
|
|
11
11
|
.autocomplete__hint {
|
|
12
12
|
@include govuk-font($size: 19);
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
// the following makes the autocomplete inherit error styles
|
|
16
|
+
// it won't work in IE11 but selects won't be enhanced into autocompletes in IE11
|
|
17
|
+
|
|
18
|
+
.govuk-form-group--error div:has(+ .govuk-select--error[data-module='hmrc-accessible-autocomplete']) > .autocomplete__wrapper .autocomplete__input {
|
|
19
|
+
border-color: #d4351c;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// the following makes the dropdown arrow appear when showing all values
|
|
23
|
+
|
|
24
|
+
.autocomplete__dropdown-arrow-down {
|
|
25
|
+
z-index: 0;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
}
|
package/hmrc/all.js
CHANGED
|
@@ -489,12 +489,6 @@
|
|
|
489
489
|
}
|
|
490
490
|
});
|
|
491
491
|
};
|
|
492
|
-
var wrapLink = function wrapLink($elem) {
|
|
493
|
-
var $wrapper = document.createElement('div');
|
|
494
|
-
$wrapper.classList.add('hmrc-timeout-dialog__link-wrapper');
|
|
495
|
-
$wrapper.appendChild($elem);
|
|
496
|
-
return $wrapper;
|
|
497
|
-
};
|
|
498
492
|
var setupDialog = function setupDialog(signoutTime) {
|
|
499
493
|
var $element = utils.generateDomElementFromString('<div>');
|
|
500
494
|
if (settings.title) {
|
|
@@ -511,17 +505,20 @@
|
|
|
511
505
|
$visualMessge.appendChild(document.createTextNode(" ".concat(settings.messageSuffix)));
|
|
512
506
|
}
|
|
513
507
|
var $staySignedInButton = utils.generateDomElementFromStringAndAppendText('<button id="hmrc-timeout-keep-signin-btn" class="govuk-button">', settings.keepAliveButtonText);
|
|
508
|
+
var $wrapper = document.createElement('div');
|
|
509
|
+
$wrapper.classList.add('govuk-button-group');
|
|
510
|
+
$wrapper.appendChild($staySignedInButton);
|
|
514
511
|
$element.appendChild($visualMessge);
|
|
515
512
|
$element.appendChild($audibleMessage);
|
|
516
|
-
$element.appendChild($staySignedInButton);
|
|
517
513
|
$staySignedInButton.addEventListener('click', keepAliveAndClose);
|
|
518
514
|
$element.appendChild(document.createTextNode(' '));
|
|
519
515
|
if (!settings.hideSignOutButton) {
|
|
520
516
|
var $signOutButton = utils.generateDomElementFromStringAndAppendText('<a id="hmrc-timeout-sign-out-link" class="govuk-link hmrc-timeout-dialog__link">', settings.signOutButtonText);
|
|
521
517
|
$signOutButton.addEventListener('click', signOut);
|
|
522
518
|
$signOutButton.setAttribute('href', settings.signOutUrl);
|
|
523
|
-
$
|
|
519
|
+
$wrapper.appendChild($signOutButton);
|
|
524
520
|
}
|
|
521
|
+
$element.appendChild($wrapper);
|
|
525
522
|
var dialogControl = dialog.displayDialog($element);
|
|
526
523
|
cleanupFunctions.push(function () {
|
|
527
524
|
dialogControl.closeDialog();
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Copied from https://gist.github.com/adamliptrot-oc/f7cbb92f040082cc17cff27416ae348b
|
|
2
|
+
// Not intended for use by teams, fixes for the following are now built into hmrc-frontend
|
|
3
|
+
// This is included here for use during automated testing to check that our fixes don't
|
|
4
|
+
// conflict with the polyfill if teams are still using it when they upgrade to a new version
|
|
5
|
+
// of hmrc-frontend which has the fixes built in.
|
|
6
|
+
// ---------------------------
|
|
7
|
+
|
|
8
|
+
// Note - updated to work with the HMRC Frontend implementation
|
|
9
|
+
// https://github.com/hmrc/play-frontend-hmrc#adding-accessible-autocomplete-css-and-javascript
|
|
10
|
+
|
|
11
|
+
if (typeof HMRCAccessibleAutocomplete != 'undefined' && document.querySelector('[data-module="hmrc-accessible-autocomplete"]') != null) {
|
|
12
|
+
var originalSelect = document.querySelector('[data-module="hmrc-accessible-autocomplete"]');
|
|
13
|
+
// load autocomplete - now handled by the HMRC component wrapper in Twirl
|
|
14
|
+
// accessibleAutocomplete.enhanceSelectElement({
|
|
15
|
+
// selectElement: originalSelect,
|
|
16
|
+
// showAllValues: true
|
|
17
|
+
// });
|
|
18
|
+
|
|
19
|
+
// =====================================================
|
|
20
|
+
// Polyfill autocomplete once loaded
|
|
21
|
+
// =====================================================
|
|
22
|
+
var checkForLoad = setInterval(checkForAutocompleteLoad, 50);
|
|
23
|
+
var parentForm = upTo(originalSelect, 'form');
|
|
24
|
+
|
|
25
|
+
function polyfillAutocomplete(){
|
|
26
|
+
var combo = parentForm.querySelector('[role="combobox"]');
|
|
27
|
+
|
|
28
|
+
// =====================================================
|
|
29
|
+
// Update autocomplete once loaded with fallback's aria attributes
|
|
30
|
+
// Ensures hint and error are read out before usage instructions
|
|
31
|
+
// =====================================================
|
|
32
|
+
if(originalSelect && originalSelect.getAttribute('aria-describedby') > ""){
|
|
33
|
+
if(parentForm){
|
|
34
|
+
if(combo){
|
|
35
|
+
combo.setAttribute('aria-describedby', originalSelect.getAttribute('aria-describedby') + ' ' + combo.getAttribute('aria-describedby'));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// =====================================================
|
|
40
|
+
// Update autocomplete once loaded with error styling if needed
|
|
41
|
+
// This won't work if the autocomplete css is loaded after the frontend library css because
|
|
42
|
+
// the autocomplete's border will override the error class's border (they are both the same specificity)
|
|
43
|
+
// but we can use the class assigned to build a more specific rule
|
|
44
|
+
// =====================================================
|
|
45
|
+
setErrorClass();
|
|
46
|
+
function setErrorClass(){
|
|
47
|
+
if(originalSelect && originalSelect.classList.contains("govuk-select--error")){
|
|
48
|
+
if(parentForm){
|
|
49
|
+
if(combo){
|
|
50
|
+
combo.classList.add("govuk-input--error");
|
|
51
|
+
// Also set up an event listener to check for changes to input so we know when to repeat the copy
|
|
52
|
+
combo.addEventListener('focus', function(){setErrorClass()});
|
|
53
|
+
combo.addEventListener('blur', function(){setErrorClass()});
|
|
54
|
+
combo.addEventListener('change', function(){setErrorClass()});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// =====================================================
|
|
61
|
+
// Ensure when user replaces valid answer with a non-valid answer, then valid answer is not retained
|
|
62
|
+
// =====================================================
|
|
63
|
+
var holdSubmit = true;
|
|
64
|
+
parentForm.addEventListener('submit', function(e){
|
|
65
|
+
if(holdSubmit){
|
|
66
|
+
e.preventDefault()
|
|
67
|
+
if(originalSelect.querySelectorAll('[selected]').length > 0 || originalSelect.value > ""){
|
|
68
|
+
|
|
69
|
+
var resetSelect = false;
|
|
70
|
+
|
|
71
|
+
if(originalSelect.value){
|
|
72
|
+
if(combo.value != originalSelect.querySelector('option[value="' + originalSelect.value +'"]').text){
|
|
73
|
+
resetSelect = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if(resetSelect){
|
|
77
|
+
originalSelect.value = "";
|
|
78
|
+
if(originalSelect.querySelectorAll('[selected]').length > 0){
|
|
79
|
+
originalSelect.querySelectorAll('[selected]')[0].removeAttribute('selected');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
holdSubmit = false;
|
|
85
|
+
//parentForm.submit();
|
|
86
|
+
HTMLFormElement.prototype.submit.call(parentForm); // because submit buttons have id of "submit" which masks the form's natural form.submit() function
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
function checkForAutocompleteLoad(){
|
|
92
|
+
if(parentForm.querySelector('[role="combobox"]')){
|
|
93
|
+
clearInterval(checkForLoad)
|
|
94
|
+
polyfillAutocomplete();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
// Find first ancestor of el with tagName
|
|
103
|
+
// or undefined if not found
|
|
104
|
+
function upTo(el, tagName) {
|
|
105
|
+
tagName = tagName.toLowerCase();
|
|
106
|
+
|
|
107
|
+
while (el && el.parentNode) {
|
|
108
|
+
el = el.parentNode;
|
|
109
|
+
if (el.tagName && el.tagName.toLowerCase() == tagName) {
|
|
110
|
+
return el;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Many DOM methods return null if they don't
|
|
115
|
+
// find the element they are searching for
|
|
116
|
+
// It would be OK to omit the following and just
|
|
117
|
+
// return undefined
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
@@ -6,20 +6,34 @@ function AccessibleAutoComplete($module, window, document) {
|
|
|
6
6
|
|
|
7
7
|
AccessibleAutoComplete.prototype.init = function init() {
|
|
8
8
|
if (this.$module) {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
9
|
+
const selectElement = this.$module;
|
|
10
|
+
const selectOptions = Array.from(selectElement.options);
|
|
11
|
+
const autocompleteId = selectElement.id;
|
|
12
|
+
const showAllValues = (selectElement.getAttribute('data-show-all-values') === 'true');
|
|
13
|
+
const autoselect = (selectElement.getAttribute('data-auto-select') === 'true');
|
|
14
|
+
const defaultValue = selectElement.getAttribute('data-default-value');
|
|
15
|
+
const minLength = selectElement.getAttribute('data-min-length');
|
|
13
16
|
|
|
14
17
|
const configurationOptions = {
|
|
15
|
-
selectElement
|
|
18
|
+
selectElement,
|
|
16
19
|
showAllValues,
|
|
17
20
|
autoselect,
|
|
18
21
|
defaultValue,
|
|
19
22
|
minLength,
|
|
23
|
+
onConfirm: (chosenOption) => {
|
|
24
|
+
selectElement.value = '';
|
|
25
|
+
const chosenOptionOrCurrentValue = (typeof chosenOption !== 'undefined')
|
|
26
|
+
? chosenOption
|
|
27
|
+
: document.getElementById(autocompleteId)?.value;
|
|
28
|
+
const selectedOption = [].filter.call(
|
|
29
|
+
selectOptions,
|
|
30
|
+
(option) => (option.textContent || option.innerText) === chosenOptionOrCurrentValue,
|
|
31
|
+
)[0];
|
|
32
|
+
if (selectedOption) selectedOption.selected = true;
|
|
33
|
+
},
|
|
20
34
|
};
|
|
21
35
|
|
|
22
|
-
const language =
|
|
36
|
+
const language = selectElement.getAttribute('data-language') || 'en';
|
|
23
37
|
|
|
24
38
|
if (language === 'cy') {
|
|
25
39
|
configurationOptions.tAssistiveHint = () => 'Pan fydd canlyniadau awtogwblhau ar gael, defnyddiwch y saethau i fyny ac i lawr i’w hadolygu a phwyswch y fysell ’enter’ i’w dewis.'
|
|
@@ -35,6 +49,30 @@ AccessibleAutoComplete.prototype.init = function init() {
|
|
|
35
49
|
}
|
|
36
50
|
|
|
37
51
|
window.HMRCAccessibleAutocomplete.enhanceSelectElement(configurationOptions);
|
|
52
|
+
|
|
53
|
+
const selectElementAriaDescribedBy = selectElement.getAttribute('aria-describedby') || '';
|
|
54
|
+
const autocompleteElement = document.getElementById(autocompleteId);
|
|
55
|
+
const autocompleteElementAriaDescribedBy = (autocompleteElement && autocompleteElement.getAttribute('aria-describedby')) || '';
|
|
56
|
+
const autocompleteElementMissingAriaDescribedAttrs = (
|
|
57
|
+
autocompleteElement
|
|
58
|
+
&& autocompleteElement.tagName !== 'select'
|
|
59
|
+
&& !autocompleteElementAriaDescribedBy.includes(selectElementAriaDescribedBy)
|
|
60
|
+
);
|
|
61
|
+
if (autocompleteElementMissingAriaDescribedAttrs) {
|
|
62
|
+
// if there is a hint and/or error then the autocomplete element
|
|
63
|
+
// needs to be aria-describedby these, which it isn't be default
|
|
64
|
+
// we need to check if it hasn't already been done to avoid
|
|
65
|
+
autocompleteElement.setAttribute(
|
|
66
|
+
'aria-describedby',
|
|
67
|
+
`${selectElementAriaDescribedBy} ${autocompleteElementAriaDescribedBy}`,
|
|
68
|
+
);
|
|
69
|
+
// and in case page is still using adam's patch, this should stop
|
|
70
|
+
// the select elements aria described by being added to the
|
|
71
|
+
// autocomplete element twice when that runs (though unsure if a
|
|
72
|
+
// screen reader would actually announce the elements twice if same
|
|
73
|
+
// element was listed twice in the aria-describedby attribute)
|
|
74
|
+
selectElement.setAttribute('aria-describedby', '');
|
|
75
|
+
}
|
|
38
76
|
}
|
|
39
77
|
};
|
|
40
78
|
|
|
@@ -40,6 +40,10 @@ html {
|
|
|
40
40
|
@include govuk-media-query($from: tablet) {
|
|
41
41
|
width: 435px;
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
&:focus {
|
|
45
|
+
outline: $govuk-focus-width solid $govuk-focus-colour;
|
|
46
|
+
}
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
.hmrc-timeout-dialog__message {
|
|
@@ -54,25 +58,13 @@ html {
|
|
|
54
58
|
white-space: nowrap;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
.hmrc-timeout-dialog__link-wrapper {
|
|
58
|
-
@include govuk-media-query($from: tablet) {
|
|
59
|
-
display: inline-block;
|
|
60
|
-
line-height: 2.5em;
|
|
61
|
-
vertical-align: baseline;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
61
|
.hmrc-timeout-dialog__link {
|
|
66
62
|
@include govuk-font($size: 24);
|
|
67
63
|
|
|
68
|
-
display: inline-block;
|
|
69
|
-
|
|
70
64
|
@include govuk-media-query($from: tablet) {
|
|
71
65
|
@include govuk-font($size: 19);
|
|
72
66
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
padding: 0.526315em 0.789473em 0.263157em;
|
|
76
|
-
line-height: 1.5;
|
|
67
|
+
// Same padding as govuk-button
|
|
68
|
+
padding: (govuk-spacing(2) - $govuk-border-width-form-element) govuk-spacing(2) (govuk-spacing(2) - $govuk-border-width-form-element - ($govuk-border-width-form-element / 2));
|
|
77
69
|
}
|
|
78
70
|
}
|
|
@@ -141,14 +141,6 @@ function TimeoutDialog($module, $sessionActivityService) {
|
|
|
141
141
|
});
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
const wrapLink = ($elem) => {
|
|
145
|
-
const $wrapper = document.createElement('div');
|
|
146
|
-
$wrapper.classList.add('hmrc-timeout-dialog__link-wrapper');
|
|
147
|
-
$wrapper.appendChild($elem);
|
|
148
|
-
|
|
149
|
-
return $wrapper;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
144
|
const setupDialog = (signoutTime) => {
|
|
153
145
|
const $element = utils.generateDomElementFromString('<div>');
|
|
154
146
|
|
|
@@ -181,9 +173,12 @@ function TimeoutDialog($module, $sessionActivityService) {
|
|
|
181
173
|
settings.keepAliveButtonText,
|
|
182
174
|
);
|
|
183
175
|
|
|
176
|
+
const $wrapper = document.createElement('div');
|
|
177
|
+
$wrapper.classList.add('govuk-button-group');
|
|
178
|
+
$wrapper.appendChild($staySignedInButton);
|
|
179
|
+
|
|
184
180
|
$element.appendChild($visualMessge);
|
|
185
181
|
$element.appendChild($audibleMessage);
|
|
186
|
-
$element.appendChild($staySignedInButton);
|
|
187
182
|
$staySignedInButton.addEventListener('click', keepAliveAndClose);
|
|
188
183
|
$element.appendChild(document.createTextNode(' '));
|
|
189
184
|
|
|
@@ -195,9 +190,11 @@ function TimeoutDialog($module, $sessionActivityService) {
|
|
|
195
190
|
$signOutButton.addEventListener('click', signOut);
|
|
196
191
|
$signOutButton.setAttribute('href', settings.signOutUrl);
|
|
197
192
|
|
|
198
|
-
$
|
|
193
|
+
$wrapper.appendChild($signOutButton);
|
|
199
194
|
}
|
|
200
195
|
|
|
196
|
+
$element.appendChild($wrapper);
|
|
197
|
+
|
|
201
198
|
const dialogControl = dialog.displayDialog($element);
|
|
202
199
|
|
|
203
200
|
cleanupFunctions.push(() => {
|