]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16949 Keyboard focus is lost or misplaced due to user interaction or content...
authorMathieu Suen <mathieu.suen@sonarsource.com>
Fri, 7 Oct 2022 09:35:49 +0000 (11:35 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 7 Oct 2022 20:03:00 +0000 (20:03 +0000)
server/sonar-web/src/main/js/components/controls/clipboard.tsx

index c72336dc7fa8c44082d9428fdc6657240e33931b..34fe96012bdcdc4ac74e91f44f0533e403bccbda 100644 (file)
@@ -32,7 +32,6 @@ export interface State {
 interface RenderProps {
   setCopyButton: (node: HTMLElement | null) => void;
   copySuccess: boolean;
-  role: string;
 }
 
 interface Props {
@@ -77,6 +76,9 @@ export class ClipboardBase extends React.PureComponent<Props, State> {
   handleSuccessCopy = () => {
     if (this.mounted) {
       this.setState({ copySuccess: true });
+      if (this.copyButton) {
+        this.copyButton.focus();
+      }
       setTimeout(() => {
         if (this.mounted) {
           this.setState({ copySuccess: false });
@@ -88,8 +90,7 @@ export class ClipboardBase extends React.PureComponent<Props, State> {
   render() {
     return this.props.children({
       setCopyButton: this.setCopyButton,
-      copySuccess: this.state.copySuccess,
-      role: 'button'
+      copySuccess: this.state.copySuccess
     });
   }
 }