From 67bf505e5fd7df1e06994dcd9e857be9688e093f Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Fri, 7 Oct 2022 11:35:49 +0200 Subject: [PATCH] SONAR-16949 Keyboard focus is lost or misplaced due to user interaction or content update --- .../src/main/js/components/controls/clipboard.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/sonar-web/src/main/js/components/controls/clipboard.tsx b/server/sonar-web/src/main/js/components/controls/clipboard.tsx index c72336dc7fa..34fe96012bd 100644 --- a/server/sonar-web/src/main/js/components/controls/clipboard.tsx +++ b/server/sonar-web/src/main/js/components/controls/clipboard.tsx @@ -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 { 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 { render() { return this.props.children({ setCopyButton: this.setCopyButton, - copySuccess: this.state.copySuccess, - role: 'button' + copySuccess: this.state.copySuccess }); } } -- 2.39.5