diff --git a/src/core/components/copy-to-clipboard-btn.jsx b/src/core/components/copy-to-clipboard-btn.jsx index 9c44487e2c5..87bfdc27e37 100644 --- a/src/core/components/copy-to-clipboard-btn.jsx +++ b/src/core/components/copy-to-clipboard-btn.jsx @@ -8,15 +8,35 @@ import PropTypes from "prop-types" * @constructor */ export default class CopyToClipboardBtn extends React.Component { + constructor(props) { + super(props) + this.state = { copied: false } + this.handleCopy = this.handleCopy.bind(this) + } + + handleCopy() { + this.setState({ copied: true }) + this._timer = setTimeout(() => { + this.setState({ copied: false }) + }, 2000) + } + + componentWillUnmount() { + if (this._timer) { + clearTimeout(this._timer) + } + } + render() { let { getComponent } = this.props + const { copied } = this.state const CopyIcon = getComponent("CopyIcon") return ( -