Skip to content

Commit 633b3ce

Browse files
authored
fix(docs): examples copy to clipboard icon switches to check and back to copy (#3494)
1 parent fa86090 commit 633b3ce

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

site/src/components/shortcodes/Code.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ if (filePath && fileMatch && codeToDisplay) {
9191
})
9292

9393
clipboard.on('success', (event) => {
94-
const iconFirstChild = event.trigger.querySelector('.bi')?.firstElementChild
94+
const iconFirstChild = event.trigger.querySelector('svg')?.firstElementChild
9595
const tooltipBtn = oudsWeb.Tooltip.getInstance(event.trigger)
9696
const namespace = 'http://www.w3.org/1999/xlink'
9797
const originalXhref = iconFirstChild?.getAttributeNS(namespace, 'href')
98-
const isCheckIconVisible = originalXhref.includes('#check2')
98+
const isCheckIconVisible = originalXhref?.includes('#check2')
9999

100100
if (isCheckIconVisible) {
101101
return
@@ -114,13 +114,14 @@ if (filePath && fileMatch && codeToDisplay) {
114114
event.clearSelection()
115115

116116
if (originalXhref) {
117-
iconFirstChild?.setAttributeNS(namespace, 'href', originalXhref.replace('clipboard', 'check2'))
117+
iconFirstChild?.setAttributeNS(namespace, 'href', originalXhref.replace('copy', 'check2'))
118118
}
119119

120120
setTimeout(() => {
121121
if (originalXhref) {
122122
iconFirstChild?.setAttributeNS(namespace, 'href', originalXhref)
123123
}
124+
tooltipBtn?.hide()
124125
}, 2000)
125126
})
126127

0 commit comments

Comments
 (0)