Skip to content

Commit

Permalink
Create rule S6846: DOM elements should not use the "accesskey" proper…
Browse files Browse the repository at this point in the history
…ty (#3435)
  • Loading branch information
github-actions[bot] authored Nov 14, 2023
1 parent e03055c commit e6ac36b
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
26 changes: 26 additions & 0 deletions rules/S6846/javascript/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"title": "DOM elements should not use the \"accesskey\" property",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
},
"tags": [
"accessibility",
"react"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-6846",
"sqKey": "S6846",
"scope": "All",
"defaultQualityProfiles": ["Sonar way"],
"quickfix": "infeasible",
"code": {
"impacts": {
"MAINTAINABILITY": "LOW",
"RELIABILITY": "MEDIUM"
},
"attribute": "CONVENTIONAL"
}
}
34 changes: 34 additions & 0 deletions rules/S6846/javascript/rule.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
== Why is this an issue?

The ``accesskey`` attribute, despite its potential utility, is fraught with numerous issues that limit its effectiveness and usability:

* Screen readers' implementation of ``accesskey`` largely depends on the browser used, as they rely on browsers for much of their functionality. Some screen readers may repeatedly indicate the ``accesskey`` value each time the element is encountered, potentially causing unnecessary repetition and noise for the user.
* Conflicts between ``accesskey`` shortcuts and other keyboard shortcuts, such as those of browsers, operating systems, assistive technologies, or browser extensions, are frequent. This overlap can lead to uncertainty and potentially trigger unintended actions, causing user confusion.
* While keyboard shortcuts are vital for screen reader functionality, conflicts can disable either the screen reader or ``accesskey`` shortcuts. Typically, screen reader shortcuts take precedence, disabling the ``accesskey`` but preserving screen reader functionality. However, this can cause confusion for users attempting to activate an ``accesskey``.
* No keystroke combinations can guarantee zero conflicts with all browsers, assistive technologies, or operating systems, particularly considering foreign languages. For instance, an ``accesskey`` shortcut that works in an English browser may conflict in the same browser set in another language due to different menu naming conventions.
* While using numerals instead of letters for keyboard shortcuts could reduce conflicts, it's not a foolproof solution. There's no standard correlation between numbers and web functions, which could lead to user confusion.
* Unlike the Windows environment that highlights keyboard shortcuts in menus, web pages or applications lack a standardized method to notify users about available ``accesskey`` shortcuts.
Given these concerns, it is generally recommended to avoid using ``accesskey``s.

[source,javascript,diff-id=1,diff-type=noncompliant]
----
function div() {
return <div accessKey="h" />;
}
----

Do not use ``accesskey``s at all.

[source,javascript,diff-id=1,diff-type=compliant]
----
function div() {
return <div />;
}
----

== Resources
=== Documentation

* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey[accesskey]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey[Accessibility concerns]
2 changes: 2 additions & 0 deletions rules/S6846/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}

0 comments on commit e6ac36b

Please sign in to comment.