Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLATUI-3352: integrate fixes from adams polyfill for accessible autocomplete #424

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oscarduignan
Copy link
Contributor

No description provided.

@oscarduignan oscarduignan changed the title PLATUI-3352: add initial failing acceptance tests PLATUI-3352: integrate fixes from adams polyfill for accessible autocomplete Dec 16, 2024
@oscarduignan oscarduignan force-pushed the PLATUI-3352-integrate-fixes-from-adams-polyfill branch from 6f6f98b to 2c1fe77 Compare December 17, 2024 12:19
@@ -17,6 +17,7 @@ AccessibleAutoComplete.prototype.init = function init() {
autoselect,
defaultValue,
minLength,
confirmOnBlur: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just added to check, it's the default but I think I've misunderstood something about how this works - because should select a matching option in the underlying select when input is changed if there is one isn't working as I would expect

@oscarduignan oscarduignan force-pushed the PLATUI-3352-integrate-fixes-from-adams-polyfill branch from 2c1fe77 to 7671c56 Compare December 19, 2024 16:47
@oscarduignan oscarduignan force-pushed the PLATUI-3352-integrate-fixes-from-adams-polyfill branch from 7671c56 to 2bf9f07 Compare December 19, 2024 17:00
@oscarduignan
Copy link
Contributor Author

finished the initial tests for this I think, I've marked the ones that won't work until we implement the fixes as failing so they could be merged ahead of other one if we want to review the tests for now

*/
function render(componentName, params, children = false) {
function renderString(componentName, params, children = false) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split this out because I wanted the string, could have possibly gotten the string back out from cheerio though instead, :hmm:

Comment on lines +152 to +188
it.failing('should select any option with exactly matching text on blur, even if it was not chosen from the suggestions', async () => {
await render(page, withGovukSelect({
id: 'location',
name: 'location',
attributes: {
'data-module': 'hmrc-accessible-autocomplete',
'data-auto-select': 'false',
// this is the default, but included to be explicit with test state
// auto select would mean that you don't have to enter exactly matching
// text to select on blur
},
label: {
text: 'Choose location',
},
items: [
{
value: ' ',
text: 'Choose location',
},
{
value: 'london',
text: 'London',
},
{
value: 'southwest',
text: 'South West',
},
],
}));

await expect(page).toFill('#location', 'Lon');
await acceptFirstSuggestionFor('#location');
expect(await page.$eval('select', (select) => select.value)).toBe('london');
await expect(page).toFill('#location', 'South West');
await page.$eval('#location', (input) => input.blur());
expect(await page.$eval('select', (select) => select.value)).toBe('southwest');
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the bit that I thought was additional behaviour, but actually I think adam's patch will be achieving this, it's just that my approach that I proof of concepted wouldn't be - onConfirm will get "undefined" in this case, so you have to in this case lookup the current value of the autocomplete input instead and use that to mark an option as selected

@oscarduignan
Copy link
Contributor Author

I'll update changelog tomorrow and mark ready for review, can merge these new tests in now - and in the implementation PR just remove the ".failing" modifier from the ones we are implementing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant