Ensure only the copyable element itself is hover-able/click-able

This commit is contained in:
Nick Brown 2020-04-17 23:15:02 -07:00 committed by Michael Vines
parent 459b4d06fe
commit 73922609e4
3 changed files with 11 additions and 14 deletions

View File

@ -148,7 +148,7 @@ const renderAccountRow = (account: Account) => {
balance = `${(1.0 * account.lamports) / LAMPORTS_PER_SOL}`; balance = `${(1.0 * account.lamports) / LAMPORTS_PER_SOL}`;
} }
const base58AccountPubkey = account.pubkey.toBase58() const base58AccountPubkey = account.pubkey.toBase58();
return ( return (
<tr key={account.id}> <tr key={account.id}>
<td> <td>

View File

@ -1,9 +1,9 @@
import React, { useState, ReactNode } from "react"; import React, { useState, ReactNode } from "react";
type CopyableProps = { type CopyableProps = {
text: string text: string;
children: ReactNode children: ReactNode;
} };
const popover = ( const popover = (
<div className="popover fade bs-popover-right show"> <div className="popover fade bs-popover-right show">
@ -17,17 +17,14 @@ function Copyable({ text, children }: CopyableProps) {
const copyToClipboard = () => navigator.clipboard.writeText(text); const copyToClipboard = () => navigator.clipboard.writeText(text);
const handleClick = () => const handleClick = () =>
copyToClipboard() copyToClipboard().then(() => {
.then(() => {
setShowPopover(true); setShowPopover(true);
setTimeout(setShowPopover.bind(null, false), 2500); setTimeout(setShowPopover.bind(null, false), 2500);
}); });
return ( return (
<div className="copyable"> <div className="copyable">
<div onClick={handleClick}> <div onClick={handleClick}>{children}</div>
{children}
</div>
{showPopover && popover} {showPopover && popover}
</div> </div>
); );

View File

@ -13,7 +13,7 @@ code {
.copyable { .copyable {
position: relative; position: relative;
&:hover { & > div:hover {
cursor: pointer; cursor: pointer;
} }