Skip to content

Commit df9c65e

Browse files
committed
event bubbling stopping in copy icon
1 parent 9a11b2e commit df9c65e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Common/ClipboardButton/ClipboardButton.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { useState, useEffect, useCallback } from 'react'
1818
import Tippy from '@tippyjs/react'
19-
import { copyToClipboard, noop } from '../Helper'
19+
import { copyToClipboard, noop, stopPropagation } from '../Helper'
2020
import ClipboardProps from './types'
2121
import { ReactComponent as ICCopy } from '../../Assets/Icon/ic-copy.svg'
2222
import { ReactComponent as Check } from '../../Assets/Icon/ic-check.svg'
@@ -42,10 +42,16 @@ export default function ClipboardButton({
4242
const [copied, setCopied] = useState<boolean>(false)
4343
const [enableTippy, setEnableTippy] = useState<boolean>(false)
4444

45-
const handleTextCopied = () => setCopied(true)
45+
const handleTextCopied = () => {setCopied(true)}
4646
const handleEnableTippy = () => setEnableTippy(true)
4747
const handleDisableTippy = () => setEnableTippy(false)
48-
const handleCopyContent = useCallback(() => copyToClipboard(content, handleTextCopied), [content])
48+
const handleCopyContent = useCallback(
49+
(e?) => {
50+
stopPropagation(e)
51+
copyToClipboard(content, handleTextCopied)
52+
},
53+
[content],
54+
)
4955

5056
useEffect(() => {
5157
if (!copied) return

0 commit comments

Comments
 (0)