Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.10.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ All changes included in 1.10:

## Regression fixes

- ([#13583](https://github.com/quarto-dev/quarto-cli/issues/13583)): Fix "Show All Code" and "Hide All Code" in the `code-tools` menu doing nothing when `code-copy` is enabled. (author: @mcanouil)
Comment thread
cderv marked this conversation as resolved.
- ([#14267](https://github.com/quarto-dev/quarto-cli/issues/14267)): Fix Windows paths with accented characters (e.g., `C:\Users\Sébastien\`) breaking dart-sass compilation.
- ([#14281](https://github.com/quarto-dev/quarto-cli/issues/14281)): Fix transient `.quarto_ipynb` files accumulating during `quarto preview` with Jupyter engine.
- ([#14298](https://github.com/quarto-dev/quarto-cli/issues/14298)): Fix `quarto preview` browse URL including output filename (e.g., `hello.html`) for single-file documents, breaking Posit Workbench proxied server access.
Expand Down
2 changes: 1 addition & 1 deletion src/command/render/codetools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function resolveCodeTools(format: Format, doc: Document): CodeTools {

// if we have requested toggle, make sure there are things to toggle
if (codeToolsResolved.toggle) {
const codeDetails = doc.querySelector(".cell > details > .sourceCode");
const codeDetails = doc.querySelector(".cell details.code-fold");

// we don't OJS hidden cells in this check, since when echo: false, we emit them hidden
const codeHidden = doc.querySelector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,16 @@
}
function toggleCodeHandler(show) {
return function(e) {
const detailsSrc = window.document.querySelectorAll(".cell > details > .sourceCode");
for (let i=0; i<detailsSrc.length; i++) {
const details = detailsSrc[i].parentElement;
const cellDetails = window.document.querySelectorAll(".cell details.code-fold");
for (let i=0; i<cellDetails.length; i++) {
const details = cellDetails[i];
if (show) {
details.open = true;
} else {
details.removeAttribute("open");
}
}
const cellCodeDivs = window.document.querySelectorAll(".cell > .sourceCode");
const cellCodeDivs = window.document.querySelectorAll(".cell div.sourceCode.cell-code");
const fromCls = show ? "hidden" : "unhidden";
const toCls = show ? "unhidden" : "hidden";
for (let i=0; i<cellCodeDivs.length; i++) {
Expand Down
22 changes: 22 additions & 0 deletions tests/docs/playwright/html/code-tools-toggle.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Code tools toggle with code-copy
format: html
code-fold: true
code-tools: true
code-copy: true
keep-hidden: true
---

Regression test for #13583: with `code-copy` enabled (the default), each code
block is wrapped in `div.code-copy-outer-scaffold`. The "Show All Code" /
"Hide All Code" items in the `code-tools` menu must still open/close every
folded `<details>` and reveal/hide the `echo: false` cell's source.

```{ojs}
x = 5
```

```{ojs}
//| echo: false
y = 10
```
33 changes: 33 additions & 0 deletions tests/docs/smoke-all/2026/07/18/issue-13583.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
format: html
engine: jupyter
code-fold: true
code-tools: true
code-copy: true
keep-hidden: true
_quarto:
tests:
html:
ensureHtmlElements:
- - "details.code-fold" # folded cell survives the code-copy scaffold
- "div.code-copy-outer-scaffold > div.sourceCode"
- "div.sourceCode.cell-code.hidden" # echo: false cell
- []
---

With `code-copy` enabled (the default), each code block is wrapped in a
`div.code-copy-outer-scaffold`, which broke the "Show All Code" / "Hide All
Code" `code-tools` selectors that assumed `.sourceCode` was a direct child of
`<details>` or `.cell` (issue #13583). This document checks the post-fix DOM:
the folded cell keeps its `details.code-fold`, the scaffold wraps the
`div.sourceCode`, and the `echo: false` cell (kept via `keep-hidden: true`)
still carries `div.sourceCode.cell-code.hidden`.

```{python}
print("visible, folded code")
```

```{python}
#| echo: false
print("hidden code")
```
45 changes: 45 additions & 0 deletions tests/integration/playwright/tests/html-code-tools-toggle.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { expect, test } from "@playwright/test";
import { getUrl } from "../src/utils";

// Regression test for #13583. With code-copy enabled (the default), each code
// block is wrapped in div.code-copy-outer-scaffold, which used to break the
// direct-child selectors the code-tools "Show All Code" / "Hide All Code"
// handler relied on. The toggle must still open/close every folded <details>
// and swap the hidden<->unhidden class on the echo:false cell's source.
test("code-tools Show/Hide All Code toggles folded and hidden code with code-copy", async ({
page,
}) => {
await page.goto(getUrl("html/code-tools-toggle.html"), {
waitUntil: "load",
});

const details = page.locator(".cell details.code-fold");
const hiddenCode = page.locator("div.sourceCode.cell-code.hidden");
const unhiddenCode = page.locator("div.sourceCode.cell-code.unhidden");

// Baseline: two folded cells, both collapsed; the echo:false cell's source
// is emitted hidden (keep-hidden).
await expect(details).toHaveCount(2);
await expect(details.nth(0)).toHaveJSProperty("open", false);
await expect(details.nth(1)).toHaveJSProperty("open", false);
await expect(hiddenCode).toHaveCount(1);
await expect(unhiddenCode).toHaveCount(0);

// Show All Code: every <details> opens, the hidden source becomes unhidden.
await page.locator("#quarto-code-tools-menu").click();
await page.locator("#quarto-show-all-code").click();

await expect(details.nth(0)).toHaveJSProperty("open", true);
await expect(details.nth(1)).toHaveJSProperty("open", true);
await expect(hiddenCode).toHaveCount(0);
await expect(unhiddenCode).toHaveCount(1);

// Hide All Code: every <details> closes, the source goes back to hidden.
await page.locator("#quarto-code-tools-menu").click();
await page.locator("#quarto-hide-all-code").click();

await expect(details.nth(0)).toHaveJSProperty("open", false);
await expect(details.nth(1)).toHaveJSProperty("open", false);
await expect(hiddenCode).toHaveCount(1);
await expect(unhiddenCode).toHaveCount(0);
});
Loading