Skip to content

Commit

Permalink
fix(checks/keyboard): make no-focusable-content use messageKey the ri…
Browse files Browse the repository at this point in the history
…ght way
  • Loading branch information
dan-tripp committed Oct 14, 2021
1 parent 4d7ed70 commit 872351d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 4 additions & 6 deletions lib/checks/keyboard/no-focusable-content-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ function noFocusableContentEvaluate(node, options, virtualNode) {
try {
const focusableDescendants = getFocusableDescendants(virtualNode);
if(focusableDescendants.length > 0) {
const unreliableElems = focusableDescendants.filter(descendant => usesUnreliableHidingStrategy(descendant));
if(unreliableElems.length > 0) {
const ids = unreliableElems.map(node => node.attr('id'));
const msg = `Using negative tabindex is not a reliable way of hiding interactive elements. `
+`Element id(s): [${ids.map(id => '"'+id+'"')}].`;
this.data({messageKey: 'info', values: msg});
const notHiddenElements = focusableDescendants.filter(descendant => usesUnreliableHidingStrategy(descendant));
if(notHiddenElements.length > 0) {
this.data({ messageKey: 'notHidden' });
this.relatedNodes(notHiddenElements);
}
}
return focusableDescendants.length === 0;
Expand Down
5 changes: 4 additions & 1 deletion lib/checks/keyboard/no-focusable-content.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"impact": "serious",
"messages": {
"pass": "Element does not have focusable descendants",
"fail": "Element has focusable descendants",
"fail": {
"default": "Element has focusable descendants",
"notHidden": "Using negative tabindex is not a reliable way of hiding interactive elements"
},
"incomplete": "Could not determine if element has descendants"
}
}
Expand Down

0 comments on commit 872351d

Please sign in to comment.