Fix copy-paste on input (#331)

If the input is active, we shouldn't override copy paste behavior
This commit is contained in:
Christopher Chedeau 2020-01-11 20:41:47 -08:00 committed by GitHub
parent d45f48e60f
commit dd2a7eb597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -295,6 +295,7 @@ export class App extends React.Component<{}, AppState> {
<div <div
className="container" className="container"
onCut={e => { onCut={e => {
if (isInputLike(e.target)) return;
e.clipboardData.setData( e.clipboardData.setData(
"text/plain", "text/plain",
JSON.stringify( JSON.stringify(
@ -308,6 +309,7 @@ export class App extends React.Component<{}, AppState> {
e.preventDefault(); e.preventDefault();
}} }}
onCopy={e => { onCopy={e => {
if (isInputLike(e.target)) return;
e.clipboardData.setData( e.clipboardData.setData(
"text/plain", "text/plain",
JSON.stringify( JSON.stringify(
@ -319,6 +321,7 @@ export class App extends React.Component<{}, AppState> {
e.preventDefault(); e.preventDefault();
}} }}
onPaste={e => { onPaste={e => {
if (isInputLike(e.target)) return;
const paste = e.clipboardData.getData("text"); const paste = e.clipboardData.getData("text");
this.addElementsFromPaste(paste); this.addElementsFromPaste(paste);
e.preventDefault(); e.preventDefault();