Skip to content

fix(html): make code-tools toggle work when code-copy is enabled#14707

Open
mcanouil wants to merge 1 commit into
quarto-dev:mainfrom
mcanouil:fix/13583-code-tools-code-copy
Open

fix(html): make code-tools toggle work when code-copy is enabled#14707
mcanouil wants to merge 1 commit into
quarto-dev:mainfrom
mcanouil:fix/13583-code-tools-code-copy

Conversation

@mcanouil

@mcanouil mcanouil commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

The code-copy scaffold introduced in 1.8.15 wraps each code block in a div.code-copy-outer-scaffold, which broke the "Show All Code" / "Hide All Code" handler's direct-child selectors. The menu rendered but clicks did nothing. Selectors now key off details.code-fold and div.sourceCode.cell-code, which the scaffold cannot displace.

  • Fixes the fold toggle, which matched zero elements and also mistook the scaffold for the <details>.
  • Fixes the hidden/unhidden toggle for echo: false cells under keep-hidden: true, broken the same way but not reported (found/verified during Claude's review).
  • Applies the same selector to the server-side toggle detection, which previously worked only because that post-processor happens to run before the scaffold is inserted.
  • Also picks up folded blocks with filename, and folded blocks inside tabsets, callouts and listings, which the old direct-child selector never reached.

Verified in headless Chromium by clicking both menu items on a rendered document: all folded blocks open and close together and the hidden block flips both ways. Patching the selectors back to their previous form on the same page reproduces the inert behaviour.

Closes #13583.

The code-copy scaffold added in 1.8.15 wraps each code block in a
div.code-copy-outer-scaffold, which left the "Show All Code" and
"Hide All Code" handler matching nothing: its selectors assumed
.sourceCode was a direct child of <details> and of .cell, and it
reached the <details> via .parentElement.

Key the selectors off details.code-fold and div.sourceCode.cell-code
instead, which the scaffold cannot displace. Apply the same selector
to the server-side toggle detection, which until now only worked
because that post-processor happens to run before the scaffold is
inserted.
@mcanouil mcanouil added bug Something isn't working regression Functionality that used to work but now is broken. code-blocks labels Jul 19, 2026
@mcanouil mcanouil self-assigned this Jul 19, 2026
@posit-snyk-bot

posit-snyk-bot commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working code-blocks regression Functionality that used to work but now is broken.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

code-tools buttons don't work if code-copy is enabled

2 participants