Skip to content

Commit 9956e56

Browse files
fix: copy the correct code block (#1406)
* bug: Fix copy button copying wrong code for Issue #1403 * fix: copy the correct code block * format --------- Co-authored-by: Chew Tee Ming <[email protected]>
1 parent 47deef9 commit 9956e56

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

packages/site-kit/src/lib/components/Text.svelte

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@
3333
.find((node) => (node as HTMLElement).classList.contains('code-block')) as HTMLElement;
3434
3535
const ts = !!parent.querySelector('.ts-toggle:checked');
36-
const code = parent.querySelector(
37-
`pre[data-language]:${ts ? 'last' : 'first'}-of-type code`
38-
) as HTMLElement;
39-
36+
const query = ts ? `pre[data-language="ts"] code` : 'pre code';
37+
const code = parent.querySelector(query) as HTMLElement;
4038
navigator.clipboard.writeText(get_text(code));
4139
}
4240
}

0 commit comments

Comments
 (0)