diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e5c983..2d81cb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### v5.0.3 + +- [fix] Restore the copy functionality for transaction hashes + ### v5.0.2 - [fix] Fixed the bug where the to address on the transaction page might be incorrectly replaced diff --git a/package.json b/package.json index 1f3ad2e..2a8bac1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metasuites", - "version": "5.0.2", + "version": "5.0.3", "repository": { "type": "git", "url": "https://github.com/blocksecteam/metasuites.git" diff --git a/src/common/components/CopyButton/index.tsx b/src/common/components/CopyButton/index.tsx index c75e7d4..7ad9058 100644 --- a/src/common/components/CopyButton/index.tsx +++ b/src/common/components/CopyButton/index.tsx @@ -130,18 +130,15 @@ const CopyButton: FC> = ({ diff --git a/src/common/scripts/copy-address.tsx b/src/common/scripts/copy-address.tsx index 21891b2..daa115d 100644 --- a/src/common/scripts/copy-address.tsx +++ b/src/common/scripts/copy-address.tsx @@ -25,37 +25,70 @@ const PhalconExplorerButton: FC<{ hash: string }> = ({ hash }) => { if (!chain) return null return ( - + + + + ) } -const appendIconToElement = (el: HTMLElement, reactNode: ReactNode) => { +const appendIconToElement = ( + el: HTMLElement, + reactNode: ReactNode, + isTxHash = false +) => { if (!isMobile()) { el.onmouseover = () => { - const btnEl = el.querySelector( + const btnEls = el.querySelectorAll( '.__metadock-copy-address-btn__' ) - if (btnEl) btnEl.style.display = 'inline-block' + if (btnEls.length) { + btnEls.forEach(btnEl => { + btnEl.style.display = 'inline-block' + }) + } } el.onmouseout = () => { - const btnEl = el.querySelector( + const btnEls = el.querySelectorAll( '.__metadock-copy-address-btn__' ) - if (btnEl) btnEl.style.display = 'none' + if (btnEls.length) { + btnEls.forEach(btnEl => { + btnEl.style.display = 'none' + }) + } } } - el.setAttribute('style', 'padding-right:18px;position:relative') + if (isTxHash) { + el.setAttribute( + 'style', + 'padding-right:40px;position:relative;max-width:11rem;' + ) + } else { + el.setAttribute('style', 'padding-right:18px;position:relative') + } const rootEl = document.createElement('span') rootEl.classList.add('__metadock-copy-address-btn__') - rootEl.setAttribute( - 'style', - `position:absolute;right:0;display:${isMobile() ? 'inline-block' : 'none'}` - ) + if (isTxHash) { + rootEl.setAttribute( + 'style', + `position:absolute;right:0;display:${ + isMobile() ? 'inline-block' : 'none' + };line-height:0;top: 50%;transform: translateY(-50%)` + ) + } else { + rootEl.setAttribute( + 'style', + `position:absolute;right:0;display:${ + isMobile() ? 'inline-block' : 'none' + }` + ) + } el?.appendChild(rootEl) createRoot(rootEl).render(reactNode) } @@ -104,7 +137,11 @@ export const handleTxnNodeListCopy = ( const txnHash = href.match(PATTERN_EVM_TX_HASH)?.[0] const hashTagEl = targetPosition === 'parent' ? el.parentElement : el if (hashTagEl && txnHash) { - appendIconToElement(hashTagEl, ) + appendIconToElement( + hashTagEl, + , + true + ) } } }