Skip to content

Commit 55ded2e

Browse files
committed
autocomplete enhancement quantity field removed:
1 parent a1eed77 commit 55ded2e

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

lib/rules/autocomplete-a11y-matches.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,52 @@ function nodeIsASearchFunctionality(actualNode, currLevel = 0, maxLevels = 4) {
5757
return currentLevelSearch(actualNode, currLevel);
5858
}
5959

60+
function quantityField(node) {
61+
const keywords = [
62+
'qty',
63+
'quantity',
64+
'quantities',
65+
'km',
66+
'kilometer',
67+
'drive',
68+
'code',
69+
'mileage',
70+
'power',
71+
'fuel'
72+
];
73+
const attributes = [
74+
'name',
75+
'id',
76+
'title',
77+
'placeholder',
78+
'aria-label',
79+
'data-label',
80+
'data-title',
81+
'data-placeholder',
82+
'role'
83+
];
84+
for (const attr of attributes) {
85+
if (node.hasAttribute(attr)) {
86+
const value = node.getAttribute(attr).toLowerCase();
87+
for (const keyword of keywords) {
88+
if (value && value.includes(keyword.toLowerCase())) {
89+
return true;
90+
}
91+
}
92+
}
93+
}
94+
return false;
95+
}
96+
6097
function autocompleteA11yMatches(node, virtualNode) {
6198
const a11yEngineFlag = true;
6299
/* the flag is used to tell autocomplete matcher that it is being called
63100
by a11y-engine and thus bypass an if block
64101
The second condition is to check we are not matching with search functionality */
65102
return (
66103
autocompleteMatches(node, virtualNode, a11yEngineFlag) &&
67-
!nodeIsASearchFunctionality(node)
104+
!nodeIsASearchFunctionality(node) &&
105+
!quantityField(node)
68106
);
69107
}
70108

0 commit comments

Comments
 (0)