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.

pull/5905/head
Jason Stirnaman 2025-03-17 13:03:29 -05:00
parent c3a3fbf6e1
commit 638e8585ed
1 changed files with 2 additions and 2 deletions

View File

@ -68,7 +68,7 @@ function initialize() {
// Trigger copy failure state lifecycle
$('.copy-code').click(function () {
let text = $(this).closest('.code-controls').prev('pre')[0].innerText;
let text = $(this).closest('.code-controls').prevAll('pre:has(code)')[0].innerText;
const copyContent = async () => {
try {
@ -90,7 +90,7 @@ Disable scrolling on the body.
Disable user selection on everything but the fullscreen codeblock.
*/
$('.fullscreen-toggle').click(function () {
var code = $(this).closest('.code-controls').prev('pre').clone();
var code = $(this).closest('.code-controls').prevAll('pre:has(code)').clone();
$('#fullscreen-code-placeholder').replaceWith(code[0]);
$('body').css('overflow', 'hidden');