Skip to content

Commit 638e858

Browse files
committed
fix(code-controls): Broken in code-blocks that contain the URL selector widget: Replace jQuery .prev() with .prevAll() to find all siblings (in case they include other elements like the URL selector widget), and then take the first pre element that has a code child.
1 parent c3a3fbf commit 638e858

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

assets/js/code-controls.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function initialize() {
6868
// Trigger copy failure state lifecycle
6969

7070
$('.copy-code').click(function () {
71-
let text = $(this).closest('.code-controls').prev('pre')[0].innerText;
71+
let text = $(this).closest('.code-controls').prevAll('pre:has(code)')[0].innerText;
7272

7373
const copyContent = async () => {
7474
try {
@@ -90,7 +90,7 @@ Disable scrolling on the body.
9090
Disable user selection on everything but the fullscreen codeblock.
9191
*/
9292
$('.fullscreen-toggle').click(function () {
93-
var code = $(this).closest('.code-controls').prev('pre').clone();
93+
var code = $(this).closest('.code-controls').prevAll('pre:has(code)').clone();
9494

9595
$('#fullscreen-code-placeholder').replaceWith(code[0]);
9696
$('body').css('overflow', 'hidden');

0 commit comments

Comments
 (0)