Thicket thicket
cambridge
REPOS 4

Projects covers Forester, Merry, xdge and ocaml-crockford.

W39.2026 · 21–27 Sep / Issue

Don't use \<details\> tag for collapsible sections

tangled · jonmsterling.com/ocaml-forester · did:plc:4gj3ihsdh6fn3aqq5bdnw5w3

This is an accessibility faux-pas, so we should do this with some javascript instead.

Comments

did:plc:jjiv56ot7d6sgethto3jr3r5

I'm with you on this. Ideally the structure of a section could be something like

<section>
  <header>
    <h#X>foo</h#X>
  </header>
  <div class="mainmatter">
    <!-- ... --> 
  </div>
</section>

and the expanding/collapsing behaviour would be handled by JavaScript, possibly by dynamically setting and unsetting a collapsed class of the section>div.body element. The CSS would just hide anything that is collapsed.

I think this would result in pretty graceful behaviour for non-JS-enabled viewers: when the transclusion is set to be collapsed by default (using \tranclude/expanded), in the absence of JS it would just be not expandable at all, which is (to me) a perfectly acceptable behaviour.


did:plc:4gj3ihsdh6fn3aqq5bdnw5w3

https://tangled.org/jonmsterling.com/ocaml-forester/commit/d60631f7de679243048ce71ada7fe44c29ab0235


did:plc:jjiv56ot7d6sgethto3jr3r5

Did you try this out? It is a little unusual ;-)

Image

  1. The headers are a little crazy
  2. The collapsing doesn't work at all. Everything is always expanded and there is no way to collapse anything.

did:plc:jjiv56ot7d6sgethto3jr3r5

Keep in mind, too, that we'll need to change the CSS and we need to do it in a way that doesn't impact the XML theme, so now is a good time to split the stylesheets I think.


did:plc:4gj3ihsdh6fn3aqq5bdnw5w3

Hang on, let me check if I forgot to track some changes, this definitely worked.


did:plc:4gj3ihsdh6fn3aqq5bdnw5w3

I forgot to track the changes to the stylesheet lmao. I'll split the stylesheet as you suggest.


did:plc:4gj3ihsdh6fn3aqq5bdnw5w3

Should be fixed now! @jonmsterling.com


did:plc:jjiv56ot7d6sgethto3jr3r5

This styles are fixed, but expand/collapse still doesn't do anything.


did:plc:4gj3ihsdh6fn3aqq5bdnw5w3

Another change I forgot to track 🤦‍♂️. Fixed now: https://tangled.org/jonmsterling.com/ocaml-forester/commit/d2c229903065576b4f5be01c1e6783cb1b2dc0da


did:plc:jjiv56ot7d6sgethto3jr3r5

OK, it's working now !!! Thanks so much :)

There's just one minor tweak I might like to make. Currently the section>header has display:inline, which means that you have to literally click the text to toggle the state, vs. being able to do so by clicking anywhere in it. I think maybe it might be a good idea to have it be displayed as a block. What do you think?


did:plc:4gj3ihsdh6fn3aqq5bdnw5w3

I see you already fixed this, so closing ;)