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

Fix: Release 3.4.2 PR #122

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion lib/rules/autocomplete-a11y-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,50 @@ function nodeIsASearchFunctionality(actualNode, currLevel = 0, maxLevels = 4) {
return currentLevelSearch(actualNode, currLevel);
}

function quantityField(node) {
const keywords = [
'qty',
'quantity',
'quantities',
'km',
'kilometer',
'drive',
'code',
'mileage',
'power',
'fuel'
];
const attributes = [
'name',
'id',
'title',
'placeholder',
'aria-label',
'data-label',
'data-title',
'data-placeholder',
'role'
];
return attributes.some(attr => {
if (node.hasAttribute(attr)) {
const value = node.getAttribute(attr).toLowerCase();
return keywords.some(
keyword => value && value.includes(keyword.toLowerCase())
);
}
return false;
});
}

function autocompleteA11yMatches(node, virtualNode) {
const a11yEngineFlag = true;
/* the flag is used to tell autocomplete matcher that it is being called
by a11y-engine and thus bypass an if block
The second condition is to check we are not matching with search functionality */
return (
autocompleteMatches(node, virtualNode, a11yEngineFlag) &&
!nodeIsASearchFunctionality(node)
!nodeIsASearchFunctionality(node) &&
!quantityField(node)
);
}

Expand Down
Loading