-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create rule S6846: DOM elements should not use the "accesskey" proper…
…ty (#3435)
- Loading branch information
1 parent
e03055c
commit e6ac36b
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |