Skip to content

fix: omit the content of a closed details element from the tree - #266

Merged
cmorten merged 1 commit into
guidepup:mainfrom
monsterlag:fix/issue-254-ded6
Oct 22, 2026
Merged

cmorten merged 1 commit into
guidepup:mainfrom
monsterlag:fix/issue-254-ded6

Conversation

@monsterlag

Copy link
Copy Markdown
Contributor

Note

AI-generated, not reviewed by a human. This pull request was written by an AI coding agent and then checked by a separate AI review agent, which re-ran the tests described below. No human has reviewed the code. It is submitted by @monsterlag, who runs these agents. If that does not fit how you want to receive contributions, please feel free to close it.

Issue

Partially addresses #254.

Details

A closed <details> was read in full, including content that is not rendered:

main, group, Plan details, paragraph, Hidden part, end of paragraph, end of group, end of main

As discussed in the issue, the HTML rendering section gives the details content slot content-visibility: hidden while the open attribute is absent, and CSS Containment says skipped contents must not be accessible to user-agent features (similar to display: none).

isHiddenFromAccessibilityTree now treats a node as hidden when its parent is a details element without open and the node is not the details' summary (the first summary child element, per "summary for its parent details"). This covers child elements and bare text nodes. The example above now reads:

main, group, Plan details, end of group, end of main

Open <details> elements are unchanged. This PR does not change the role of <summary>: per the discussion in the issue, the specs give it no corresponding role, so that part of the issue is left as is.

New tests in test/int/detailsSummary.int.test.ts cover a closed details (child element and text content hidden), a closed details with two summary elements (only the first is read), and an open details (content still read).

How it was tested (in a Linux container, Node 24, yarn 1.22):

  • yarn jest test/int/detailsSummary.int.test.ts before the source change: 2 of 3 tests fail (the closed details' paragraph, text and second summary are announced).
  • The same command after the change: 3 of 3 pass.
  • yarn ci (clean, lint, test:coverage, build, types:test): passes; 58 suites / 338 tests, coverage thresholds met (98.34% statements, 95.11% branches, 100% functions), attw reports no problems.

CheckList

  • Has been tested (where required).

A closed <details> renders its content (everything except its summary)
with content-visibility: hidden, which skips the contents and makes
them inaccessible, similar to display: none.

Partially addresses guidepup#254
@cmorten
cmorten merged commit 870d1a6 into guidepup:main Oct 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants