diff --git a/src/renderer/component/copyableText/index.js b/src/renderer/component/copyableText/index.js new file mode 100644 index 000000000..f759811aa --- /dev/null +++ b/src/renderer/component/copyableText/index.js @@ -0,0 +1,10 @@ +import { connect } from 'react-redux'; +import { doNotify } from 'lbry-redux'; +import CopyableText from './view'; + +export default connect( + null, + { + doNotify, + } +)(CopyableText); diff --git a/src/renderer/component/copyableText/view.jsx b/src/renderer/component/copyableText/view.jsx new file mode 100644 index 000000000..e47a37506 --- /dev/null +++ b/src/renderer/component/copyableText/view.jsx @@ -0,0 +1,63 @@ +// @flow +import * as React from 'react'; +import { clipboard } from 'electron'; +import { FormRow } from 'component/common/form'; +import Button from 'component/button'; +import * as icons from 'constants/icons'; +/* +noSnackbar added due to issue 1945 +https://github.com/lbryio/lbry-desktop/issues/1945 +"Snackbars and modals can't be displayed at the same time" +*/ +type Props = { + copyable: string, + noSnackbar: boolean, + doNotify: ({ message: string, displayType: Array }) => void, +}; + +export default class CopyableText extends React.PureComponent { + constructor() { + super(); + + this.input = null; + } + + input: ?HTMLInputElement; + + render() { + const { copyable, doNotify, noSnackbar } = this.props; + + return ( + + { + this.input = input; + }} + onFocus={() => { + if (this.input) { + this.input.select(); + } + }} + /> + +