Tweak Field.react
authorGreg Hurrell <greg@hurrell.net>
Sun, 2 Aug 2015 05:34:47 +0000 (22:34 -0700)
committerGreg Hurrell <greg@hurrell.net>
Sun, 2 Aug 2015 05:34:47 +0000 (22:34 -0700)
Edits for brevity, and add a title attribute to the copy
link span.

src/Field.react.js

index ea757c52a06eb7a2ec37c9af5c57c845463253a7..5ff4be7b258ec33ce9e887d91c735f6e098f8027 100644 (file)
@@ -70,11 +70,10 @@ export default class Field extends React.Component {
   }
 
   _onCopy = () => {
-    const input = React.findDOMNode(this._input);
-    input.select();
+    React.findDOMNode(this._input).select();
 
+    // May throw a SecurityError.
     try {
-      // May throw a SecurityError.
       document.execCommand('copy');
     } catch(error) { // eslint-disable-line no-empty
       // Swallow.
@@ -86,7 +85,14 @@ export default class Field extends React.Component {
     // doesn't work; see:
     // - https://code.google.com/p/chromium/issues/detail?id=476508
     // - https://github.com/w3c/clipboard-apis/issues/4
-    return <span className="hextrapolate-copy" onClick={this._onCopy}>copy</span>;
+    return (
+      <span
+        className="hextrapolate-copy"
+        onClick={this._onCopy}
+        title="Copy to Clipboard">
+        copy
+      </span>
+    );
   }
 
   render() {