fixes href working

pull/1335/head
filip mertens 3 years ago
parent 941d0b63e2
commit 92f36d8d53
  1. 10
      libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx

@ -6,8 +6,8 @@ import './copy-to-clipboard.css'
export const CopyToClipboard = ({ content, tip='Copy', icon='fa-copy', ...otherProps }) => { export const CopyToClipboard = ({ content, tip='Copy', icon='fa-copy', ...otherProps }) => {
const [message, setMessage] = useState(tip) const [message, setMessage] = useState(tip)
const handleClick = () => { const handleClick = (event) => {
if (content && content !== '') { // module `copy` keeps last copied thing in the memory, so don't show tooltip if nothing is copied, because nothing was added to memory if (content && content !== '') { // module `copy` keeps last copied thing in the memory, so don't show tooltip if nothing is copied, because nothing was added to memory
try { try {
if (typeof content !== 'string') { if (typeof content !== 'string') {
content = JSON.stringify(content, null, '\t') content = JSON.stringify(content, null, '\t')
@ -20,6 +20,8 @@ export const CopyToClipboard = ({ content, tip='Copy', icon='fa-copy', ...otherP
} else { } else {
setMessage('Cannot copy empty content!') setMessage('Cannot copy empty content!')
} }
event.preventDefault()
return false
} }
const reset = () => { const reset = () => {
@ -27,10 +29,10 @@ export const CopyToClipboard = ({ content, tip='Copy', icon='fa-copy', ...otherP
} }
return ( return (
<a href="#" onClick={handleClick} onMouseLeave={reset}> <a href='#' onClick={handleClick} onMouseLeave={reset}>
<OverlayTrigger placement="right" overlay={ <OverlayTrigger placement="right" overlay={
<Tooltip id="overlay-tooltip"> <Tooltip id="overlay-tooltip">
{ message } { message }
</Tooltip> </Tooltip>
}> }>
<i className={`far ${icon} ml-1 p-2`} aria-hidden="true" <i className={`far ${icon} ml-1 p-2`} aria-hidden="true"

Loading…
Cancel
Save