]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16782 [893332] The decorative image is not hidden from screen readers
authorWouter Admiraal <wouter.admiraal@sonarsource.com>
Wed, 10 Aug 2022 10:06:46 +0000 (12:06 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 11 Aug 2022 20:03:48 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/issues/sidebar/ScopeFacet.tsx
server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/ScopeFacet-test.tsx.snap
server/sonar-web/src/main/js/components/icons/QualifierIcon.tsx

index e21c5798bd505f06e9b02d8836811a7d2f46c011..f831854f4670dc94d3fea7a2a499e447cfc7fb02 100644 (file)
@@ -67,7 +67,11 @@ export default function ScopeFacet(props: ScopeFacetProps) {
                   key={scope}
                   name={
                     <span className="display-flex-center">
-                      <QualifierIcon className="little-spacer-right" qualifier={qualifier} />{' '}
+                      <QualifierIcon
+                        className="little-spacer-right"
+                        qualifier={qualifier}
+                        aria-hidden={true}
+                      />{' '}
                       {translate('issue.scope', scope)}
                     </span>
                   }
index c92cd880a4efd2a2b1233da405312dfb1f090cd3..034d490ba1adac802c3f805838dc61acd5197563 100644 (file)
@@ -27,6 +27,7 @@ exports[`should render correctly: active facet 1`] = `
           className="display-flex-center"
         >
           <QualifierIcon
+            aria-hidden={true}
             className="little-spacer-right"
             qualifier="FIL"
           />
@@ -47,6 +48,7 @@ exports[`should render correctly: active facet 1`] = `
           className="display-flex-center"
         >
           <QualifierIcon
+            aria-hidden={true}
             className="little-spacer-right"
             qualifier="UTS"
           />
@@ -103,6 +105,7 @@ exports[`should render correctly: disabled facet 1`] = `
           className="display-flex-center"
         >
           <QualifierIcon
+            aria-hidden={true}
             className="little-spacer-right"
             qualifier="FIL"
           />
@@ -124,6 +127,7 @@ exports[`should render correctly: disabled facet 1`] = `
           className="display-flex-center"
         >
           <QualifierIcon
+            aria-hidden={true}
             className="little-spacer-right"
             qualifier="UTS"
           />
@@ -165,6 +169,7 @@ exports[`should render correctly: open 1`] = `
           className="display-flex-center"
         >
           <QualifierIcon
+            aria-hidden={true}
             className="little-spacer-right"
             qualifier="FIL"
           />
@@ -185,6 +190,7 @@ exports[`should render correctly: open 1`] = `
           className="display-flex-center"
         >
           <QualifierIcon
+            aria-hidden={true}
             className="little-spacer-right"
             qualifier="UTS"
           />
index 57cef682ed514c537199796921fbf1ca43077cae..2c97d64e948831f195d8a460affe717a0b61d0bf 100644 (file)
@@ -34,22 +34,26 @@ const qualifierIcons: Dict<(props: IconProps) => React.ReactElement> = {
   vw: PortfolioIcon
 };
 
-interface QualifierIconProps {
+interface QualifierIconProps extends IconProps {
   className?: string;
   fill?: string;
   qualifier: string | null | undefined;
 }
 
-export default function QualifierIcon(props: QualifierIconProps) {
-  if (!props.qualifier) {
+export default function QualifierIcon({
+  qualifier,
+  className,
+  fill,
+  ...props
+}: QualifierIconProps) {
+  if (!qualifier) {
     return null;
   }
 
-  const qualifier = props.qualifier.toLowerCase();
-  const FoundIcon = qualifierIcons[qualifier];
-  const ariaLabel = props.qualifier != null ? translate(`qualifier.${props.qualifier}`) : undefined;
+  const FoundIcon = qualifierIcons[qualifier.toLowerCase()];
+  const ariaLabel = qualifier != null ? translate(`qualifier.${qualifier}`) : undefined;
   return FoundIcon ? (
-    <FoundIcon className={props.className} fill={props.fill} ariaLabel={ariaLabel} />
+    <FoundIcon className={className} fill={fill} ariaLabel={ariaLabel} {...props} />
   ) : null;
 }