From cc2ec5b930a080c2e8384e53aa6a130c427c47e9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:58:06 +0100 Subject: [PATCH] Create rule S6852: Elements with an interactive role should support focus (#3444) --- rules/S6852/javascript/metadata.json | 26 ++++++++++++++++++ rules/S6852/javascript/rule.adoc | 40 ++++++++++++++++++++++++++++ rules/S6852/metadata.json | 2 ++ 3 files changed, 68 insertions(+) create mode 100644 rules/S6852/javascript/metadata.json create mode 100644 rules/S6852/javascript/rule.adoc create mode 100644 rules/S6852/metadata.json diff --git a/rules/S6852/javascript/metadata.json b/rules/S6852/javascript/metadata.json new file mode 100644 index 00000000000..fbe90bb988f --- /dev/null +++ b/rules/S6852/javascript/metadata.json @@ -0,0 +1,26 @@ +{ + "title": "Elements with an interactive role should support focus", + "type": "CODE_SMELL", + "status": "ready", + "remediation": { + "func": "Constant\/Issue", + "constantCost": "5min" + }, + "tags": [ + "accessibility", + "react" + ], + "defaultSeverity": "Minor", + "ruleSpecification": "RSPEC-6852", + "sqKey": "S6852", + "scope": "All", + "defaultQualityProfiles": ["Sonar way"], + "quickfix": "infeasible", + "code": { + "impacts": { + "MAINTAINABILITY": "LOW", + "RELIABILITY": "MEDIUM" + }, + "attribute": "CONVENTIONAL" + } +} diff --git a/rules/S6852/javascript/rule.adoc b/rules/S6852/javascript/rule.adoc new file mode 100644 index 00000000000..24305270796 --- /dev/null +++ b/rules/S6852/javascript/rule.adoc @@ -0,0 +1,40 @@ +Interactive elements being focusable is vital for website accessibility. It enables users, including those using assistive technologies, to interact effectively with the website. Without this, some users may be unable to access certain features, leading to a poor user experience and potential non-compliance with accessibility standards. + +== Why is this an issue? + +Lack of focusability can hinder navigation and interaction with the website, resulting in an exclusionary user experience and possible violation of accessibility guidelines. + +== How to fix it + +Ensure that all interactive elements on your website can receive focus. This can be achieved by using standard HTML interactive elements, or by assigning a `tabindex` attribute of "0" to custom interactive components. + +=== Code examples + +==== Noncompliant code example + +[source,html,diff-id=1,diff-type=noncompliant] +---- + +Submit + + +Next page +---- + +==== Compliant solution + +[source,html,diff-id=1,diff-type=compliant] +---- + +Submit + + + Next page +---- + +== Resources +=== Documentation + + * W3C - https://www.w3.org/TR/WCAG20-TECHS/H4.html[Creating a logical tab order through links, form controls, and objects] + * W3C - https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_generalnav[Fundamental Keyboard Navigation Conventions] + * MDN - https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#accessibility_concerns[ARIA: button role - Accessibility concerns] diff --git a/rules/S6852/metadata.json b/rules/S6852/metadata.json new file mode 100644 index 00000000000..2c63c085104 --- /dev/null +++ b/rules/S6852/metadata.json @@ -0,0 +1,2 @@ +{ +}