PLATUI-3353: proof of concept - how could we integrate accessible autocomplete fixes from adam's patch #419
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
proposal is that rather than copying adam's patches, because we're in charge of initialising the autocomplete elements, we can do it more simply/safely
the issues that need fixing
adam's patch checks if there is an autocomplete on the page, and then polls until it's been setup by the accessible autocomplete javascript - we shouldn't need to do this because we are in charge of initialising the autocompletes
we can simplify the applying error styles by moving it into our css, where adam's patch is updating the dom to set a govuk error class on the autocomplete after the field changes
the aria-described by fix we can run directly after we call enhanceSelectElement
the issue with previouslySelected answers being retained we can fix by overriding the onConfirm handler for options - which triggers on blur of the field (regardless of auto select being enabled) and clearing the currently value of the underlying select, where adam's patch is hooking into the form submit
if we apply the patches in this way, then they should also work for any number of autocompletes on one page
if people are manually init'ing the autocompelte rather than using our
data-module="hmrc-accessible-autocomplete"
then they would just need to copy the js patches into their usage, which wouldn't be to onerous, since ideally not many people will be using that approach