From 98ee2c9b75b3eb06660cce5556b5eb130a31546d Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Thu, 25 Aug 2022 11:22:40 +0200 Subject: [PATCH] SONAR-16820 Text alternative is missing --- .../js/components/controls/BackButton.tsx | 19 +++++++++++-------- .../main/js/components/controls/Tooltip.tsx | 7 ++++--- .../__snapshots__/BackButton-test.tsx.snap | 2 ++ .../__snapshots__/Tooltip-test.tsx.snap | 2 -- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/server/sonar-web/src/main/js/components/controls/BackButton.tsx b/server/sonar-web/src/main/js/components/controls/BackButton.tsx index 68cc3368223..5ffe0fa483f 100644 --- a/server/sonar-web/src/main/js/components/controls/BackButton.tsx +++ b/server/sonar-web/src/main/js/components/controls/BackButton.tsx @@ -39,14 +39,17 @@ export default class BackButton extends React.PureComponent { } }; - renderIcon = () => ( - - - - ); + renderIcon = () => { + const { tooltip = translate('issues.return_to_list') } = this.props; + return ( + + + + ); + }; render() { const { tooltip = translate('issues.return_to_list') } = this.props; diff --git a/server/sonar-web/src/main/js/components/controls/Tooltip.tsx b/server/sonar-web/src/main/js/components/controls/Tooltip.tsx index 2b7b07f17b4..57452118cb6 100644 --- a/server/sonar-web/src/main/js/components/controls/Tooltip.tsx +++ b/server/sonar-web/src/main/js/components/controls/Tooltip.tsx @@ -382,6 +382,7 @@ export class TooltipInner extends React.Component { }; render() { + const isVisible = this.isVisible(); return ( <> {React.cloneElement(this.props.children, { @@ -394,10 +395,10 @@ export class TooltipInner extends React.Component { // always well supported. As a fallback, we use aria-labelledby as well. // See https://sarahmhigley.com/writing/tooltips-in-wcag-21/ // See https://css-tricks.com/accessible-svgs/ - 'aria-describedby': this.id, - 'aria-labelledby': this.id + 'aria-describedby': isVisible ? this.id : undefined, + 'aria-labelledby': isVisible ? this.id : undefined })} - {this.isVisible() && ( + {isVisible && ( diff --git a/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/BackButton-test.tsx.snap b/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/BackButton-test.tsx.snap index a4fc44f5eca..5d932f59cc1 100644 --- a/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/BackButton-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/controls/__tests__/__snapshots__/BackButton-test.tsx.snap @@ -10,6 +10,7 @@ exports[`should handle click 1`] = ` onClick={[Function]} >